Skip to content

Instantly share code, notes, and snippets.

@narma
Last active December 20, 2015 23:08
Show Gist options
  • Save narma/6209848 to your computer and use it in GitHub Desktop.
Save narma/6209848 to your computer and use it in GitHub Desktop.
(ns find-pin)
(defn ^String to-pin
[^Integer x]
(let [v (str x)]
(.concat (apply str (repeat (- 4 (count v)) 0)) v)))
(defn ^java.lang.Boolean valid-pin?
[^String v]
(and
(= 3 (count (distinct v)))
(some true?
(->> (range 10) (map str) (map #(.concat % %)) (map #(.contains v %))))))
(prn (count (filter valid-pin? (map to-pin (range 10000)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment