Assuming the above is OK, then here's my Clojure solution:
(require '[clojure.string :as s]) (defn permute [a] (or (seq (mapcat #(map (partial cons %) (permute (remove #{%} a))) a)) [[]])) (defn regex-contains-all [input] (str "(" (s/join ")|(" (map (partial s/join ".*") (permute input))) ")"))
Apologies for writing code that looks like line noise.
Given an input of "abc" then it will generate:
(regex-contains-all "abc") "(a.*b.*c)|(a.*c.*b)|(b.*a.*c)|(b.*c.*a)|(c.*a.*b)|(c.*b.*a)"
This gives the test results that I describe in the previous comment.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Assuming the above is OK, then here's my Clojure solution:
Apologies for writing code that looks like line noise.
Given an input of "abc" then it will generate:
This gives the test results that I describe in the previous comment.