Last active
December 20, 2015 23:08
-
-
Save narma/6209848 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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