SHARE
TWEET

Untitled

a guest Feb 22nd, 2014 119 Never
  1. ; Uses clojure.math.combinatorics for permutations function
  2. (ns scratchpad.core
  3.   (:require [clojure.math.combinatorics :as combo]))
  4.  
  5. (defn check-anagrams [a b]
  6.   (let [permutations (map #(apply str %) (combo/permutations a))]
  7.     (filter (fn [p] (.contains b p)) permutations)))
  8.  
  9. (check-anagrams "cat" "actor"); ("act")
  10. (check-anagrams "car" "actor"); ()
RAW Paste Data
Top