From 9de5b2fd987351d7a322807ad7de93341ae96783 Mon Sep 17 00:00:00 2001 From: Theabominog <40739610+Theabominog@users.noreply.github.com> Date: Sat, 6 Oct 2018 01:56:40 +0530 Subject: [PATCH 1/3] Update mutations_yoch.py --- intermediate/mutations_yoch.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/intermediate/mutations_yoch.py b/intermediate/mutations_yoch.py index 1642cb8..e32d663 100644 --- a/intermediate/mutations_yoch.py +++ b/intermediate/mutations_yoch.py @@ -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")) From 7e1c1cefb780ba0e52ce368d0b3f828fb04f2dad Mon Sep 17 00:00:00 2001 From: Theabominog <40739610+Theabominog@users.noreply.github.com> Date: Sat, 6 Oct 2018 13:15:54 +0530 Subject: [PATCH 2/3] Update and rename mutations_yoch.py to theabominog_mutations.py --- intermediate/{mutations_yoch.py => theabominog_mutations.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename intermediate/{mutations_yoch.py => theabominog_mutations.py} (83%) diff --git a/intermediate/mutations_yoch.py b/intermediate/theabominog_mutations.py similarity index 83% rename from intermediate/mutations_yoch.py rename to intermediate/theabominog_mutations.py index e32d663..10cb74a 100644 --- a/intermediate/mutations_yoch.py +++ b/intermediate/theabominog_mutations.py @@ -1,6 +1,6 @@ def mutation(p, q): - small = q.lower() - large = p.lower() + large = q.lower() + small = p.lower() for letter in str(small): if letter not in str(large): return False From 5bdf73b28db8b01090ae31e407e8b10ab56d14a9 Mon Sep 17 00:00:00 2001 From: Theabominog <40739610+Theabominog@users.noreply.github.com> Date: Sat, 6 Oct 2018 13:17:04 +0530 Subject: [PATCH 3/3] Create mutations_yoch.py --- intermediate/mutations_yoch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 intermediate/mutations_yoch.py diff --git a/intermediate/mutations_yoch.py b/intermediate/mutations_yoch.py new file mode 100644 index 0000000..e32d663 --- /dev/null +++ b/intermediate/mutations_yoch.py @@ -0,0 +1,11 @@ +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 + +print(mutation("Hello", "hello")) +print(mutation("alien", "line")) +print(mutation("haahaha", "ght"))