;; word-breaks (def dict #{"a" "apple" "applepie" "base" "baseball" "bat" "gift" "i" "pi" "pie" "twist"}) (defn permute [ss] (distinct (mapcat identity (let [cnt (count ss) coll (take cnt (iterate rest ss))] (for [n (range 1 (inc cnt))] (mapcat (fn [x] (map (fn [y] (apply str y)) (partition n x))) coll)))))) (defn find-word-bounds [ss] (filter dict (permute ss)))