Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Explode string containing ambiguous characters
(ns playground.explode
(:require [clojure.math.combinatorics :refer [cartesian-product]]
[clojure.string :as str]))
(def ambiguous-chars [#{\O \0} #{\I \L \1}])
(defn ambiguate
(or (first (filter #(contains? % c) ambiguous-chars))
(defn explode
(map str/join (apply cartesian-product (map ambiguate s))))
(explode "PHONIC")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment