-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractical7.py
More file actions
29 lines (26 loc) · 1.14 KB
/
Copy pathpractical7.py
File metadata and controls
29 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Name : PRATHAM MODI
# ID : 20CE056
# Aim : Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check for lapindrome. For example gaga is a lapindrome, since the two halves ga and ga have the same characters with same frequency. Also, abccab, rotor and xyzxy are a few examples of lapindromes. Note that abbaab is NOT a lapindrome. The two halves contain the same characters but their frequencies do not match. Your task is simple. Given a string, you need to tell if it is a lapindrome.
# GITHUB LINK : https://github.com/prathammodi333/python-programs
n = int(input())
def checkLap(s):
s1,s2='',''
if(len(s)%2==0):
s1=s[:len(s)//2]
s2=s[len(s)//2:]
else:
s1=s[:len(s)//2]
s2=s[len(s)//2+1:]
l1=list(s1)
l2=list(s2)
l1.sort()
l2.sort()
s1=str(l1)
s2=str(l2)
if(s1==s2):
print('YES')
else:
print('NO')
for i in range(n):
s = input()
checkLap(s)