-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrial.py
More file actions
39 lines (35 loc) · 769 Bytes
/
trial.py
File metadata and controls
39 lines (35 loc) · 769 Bytes
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
def is_permutation(string1, string2):
if len(string1) != len(string2):
return False
if string1 == string2:
return False
ht = dict()
for char in string1:
ht[char] = ht[char] + 1 if char in ht else 1
for char in string2:
if char in ht:
ht[char] = ht[char] - 1
if ht[char] < 0:
return False
else:
return False
return True
def is_permutation_sorted(string1, string2):
if len(string1) != len(string2):
return False
if string1 == string2:
return False
str1 = sorted(string1)
print(str1)
str2 = sorted(string2)
print(str2)
if str1 == str2:
return True
return False
def main():
string1 = "sumeyya"
string2 = "umeyyas"
iu = is_permutation_sorted(string1.lower(), string2.lower())
print(iu)
if __name__ == "__main__":
main()