From 226c8a16ff7399a9f67f21bf4b4538efab45c0db Mon Sep 17 00:00:00 2001 From: Palash Jain Date: Fri, 5 Oct 2018 23:47:15 +0530 Subject: [PATCH] Solution for mutation problem --- intermediate/mutation_codilis.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 intermediate/mutation_codilis.py diff --git a/intermediate/mutation_codilis.py b/intermediate/mutation_codilis.py new file mode 100644 index 0000000..813bedb --- /dev/null +++ b/intermediate/mutation_codilis.py @@ -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))