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

Solution for Issue #3, mutations, in python #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
38 changes: 38 additions & 0 deletions python/intermediate/mutations_bpbrum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
def mutations(strings_list):
first_list = [letter for letter in strings_list[0].lower()]
second_str = strings_list[1].lower()
for letter in second_str:
if letter not in first_list:
return False
else:
first_list.remove(letter)
return True

def testing(tests, expected_output):
assert len(tests) == len(expected_output)
outputs = list()
fails = 0
for test in tests:
outputs.append(mutations(test))

for index, output in enumerate(outputs):
try:
assert output == expected_output[index]
except AssertionError:
print("Error in test {}".format(index))
print("## Output: {}".format(output))
print("## Expected: {}".format(expected_output[index]))
fails += 1

print("\n###############################################")
print("Ran {} tests.".format(len(tests)))
if fails > 0:
print("FAILED")
print("{} failures".format(fails))
else:
print("OK")

if __name__ == "__main__":
tests = [["hel", "heel"], ["hello", "Hello"], ["hello", "hey"], ["Alien", "line"]]
expected_output = [False, True, False, True]
testing(tests, expected_output)