re: Daily Coding Puzzles - Nov 4th - Nov 9th VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION
 

Common Lisp


(defun scramble (source target)
          (let ((source (coerce source 'list))
                (target (coerce target 'list)))
            (cond ((null target) t) 
                  ((member (first target) source)
                   (scramble (remove (first target) source :count 1)
                             (rest target))))))

(mapcar #'(lambda (args) (apply #'scramble args))
        '(("rkqodlw" "world")
          ("cedewaraaossoqqyt" "codewars")
          ("katas" "steak")
          ("scriptjavx" "javascript")
          ("scriptingjava" "javascript")
          ("scriptsjava" "javascripts")
          ("javscripts" "javascript")
          ("aabbcamaomsccdd" "commas")
          ("commas" "commas")
          ("sammoc" "commas")))
;; => (T T NIL NIL T T NIL T T T)
code of conduct - report abuse