-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlamindrome.py
59 lines (52 loc) · 1.18 KB
/
lamindrome.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# t = int(input())
# for case in range (t):
# word = input()
# word = list(word)
# set1 = set()
# set2 = set()
# wordlen = len(word)
# mid = wordlen//2
# left = word[:mid]
# leftTemp = word[:mid]
# if wordlen%2 == 1:
# right = word[mid+1:]
# else:
# right = word[mid:]
# for i in range (mid):
# set1.add(left[i])
# set2.add(right[i])
# if set1 != set2:
# print("NO")
# continue
# else:
# for i in left:
# if i in right:
# leftTemp.pop(0)
# right.pop(right.index(i))
# else:
# print("NO")
# break
# if leftTemp == right:
# print("YES")
ans=[]
for i in range(int(input())):
w=input()
l=len(w)
if l%2==1:
m=l//2
left=w[:m]
right=w[m+1:]
else:
m=l//2
left=w[:m]
right=w[m:]
ansl=list(left)
ansr=list(right)
ansl.sort()
ansr.sort()
if''.join(ansl)==''.join(ansr):
ans.append("lamindrome")
else:
ans.append("not a lamindrome")
for item in ans:
print(item)