-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnearly_equal1.py
More file actions
executable file
·44 lines (36 loc) · 875 Bytes
/
Copy pathnearly_equal1.py
File metadata and controls
executable file
·44 lines (36 loc) · 875 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
40
41
42
43
44
def permutate(word):
if not word:
return [word]
else:
temp = []
for i in range(len(word)):
part = word[:i] + word[i+1:]
for m in permutate(part):
st = word[i:i+1] + m
if st not in temp:
temp.append(st)
return temp
def mutate(word,search=None):
chars = 'abcdefghijklmnopqrstuvwxyz'
l = [i for i in word]
new_words = []
#removing one char
for i in range(len(word))
nw = word[:i]+word[i+1])
new_words.append(nw)
print new_words
def nearly_equal(word,word1):
if word == word1:
print "both are equal"
return
elif len(word) > len(word1):
word,word1 = word1,word
#words_list = mutate(new)
if mutate(word,word1):
print "Both are nearly equal"
else:
print "Both are not equal"
if __name__ == "__main__":
import sys
#mutate(sys.argv[1])
nearly_equal(sys.argv[1],sys.argv[2])