← coderbyte_practice

correct code

5418697c6475b10a0f9eaa2f2397930a72a38386 · ovidiucs · May 7, 2015 09:36

+9 −9 · 1 file changed

  • medium/06-string-scramble.py +9 −9
diff --git a/medium/06-string-scramble.py b/medium/06-string-scramble.py
index 4c90a7f..25c50e5 100644
--- a/medium/06-string-scramble.py
+++ b/medium/06-string-scramble.py
@@ -1,12 +1,13 @@
 def StringScramble(str1,str2):
 
-    ll = (set(str1) & set(str2))
-    # for n in ll:
-    #     if n in str1 or str2:
-    #         print 'f',n
+    lst = list(str1)
 
-    if len(ll ^ set(str2)) and len(ll ^ set(str1)):
-        return 'false'
+    for i in str2:
+        if i in lst:
+            lst.remove(i)
+            print lst
+        else:
+            return 'false'
     return 'true'
 
 """
@@ -19,7 +20,6 @@ otherwise return the string false.
 For example: if str1 is "rkqodlw" and str2 is "world"
 the output should return true.
 Punctuation and symbols will not be entered with the parameters.
-
 """
 # keep this function call here  
 # to see how to enter arguments in Python scroll down
@@ -30,8 +30,8 @@ print StringScramble("heloooolwrdlla","helloworld")
 print StringScramble("coamamaaqq","comma")
 print StringScramble("letrrkakaeaaaqq","letter")
 print StringScramble("aqwe","qa")
-print StringScramble("yelowrqwedlk","yellowred")
+print StringScramble("yelowrqwedk","yellowred")
 print StringScramble("cdore","coder")
-
+print StringScramble("win33er","winner")
 # Input = "cdore" & str2= "coder"Output = "true"
 # Input = "h3llko" & str2 = "hello"Output = "false"
\ No newline at end of file