Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mutations_yoch.py #47

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions intermediate/mutations_yoch.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from collections import Counter
def mutation(p, q):
small = q.lower()
large = p.lower()
for letter in str(small):
if letter not in str(large):
return False
return True

def mutations(s1, s2):
c1 = Counter(map(str.lower, s1))
c2 = Counter(map(str.lower, s2))
c1.subtract(c2)
return all(n >= 0 for n in c1.values())

tests = [
(["hello", "Hello"], True),
(["hello", "hey"], False),
(["Alien", "line"], True),
(["hel", "heel"], False)
]

for test, excepted in tests:
ret = mutations(*test)
assert ret == excepted
print(mutation("Hello", "hello"))
print(mutation("alien", "line"))
print(mutation("haahaha", "ght"))