Skip to content

Commit

Permalink
Merge pull request #43 from Codilis/master
Browse files Browse the repository at this point in the history
Solution for mutation problem
the-vampiire authored Oct 5, 2018
2 parents 1286456 + 226c8a1 commit 9c0495f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions intermediate/mutation_codilis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def mutation(s):
alpha = []
s[0] = s[0].lower()
s[1] = s[1].lower()
for i in range(2):
alpha.append([0 for _ in range(26)])

if(len(s[0]) < len(s[1])):
return False

for i in range(len(s[1])):
alpha[0][ord(s[0][i])-97] += 1
alpha[1][ord(s[1][i])-97] += 1

for j in range(i, len(s[0])):
alpha[0][ord(s[0][j])-97] += 1

for i in range(26):
if alpha[1][i] > alpha[0][i]:
return False

return True


Test = [["hello", "Hello"],
["hello", "hey"],
["Alien", "line"],
['hel', 'heel'],
['heloes', 'hello']]

for test in Test:
print(mutation(test))

0 comments on commit 9c0495f

Please sign in to comment.