Last active
August 29, 2015 14:00
Revisions
-
killme2008 revised this gist
Apr 30, 2014 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,12 +4,11 @@ (Integer/valueOf x)))) (defn- say-what [inputs words n] (let [[x y z] inputs rs (filter #(zero? (rem n %)) inputs)] (cond ;;rule 5 (.contains (str n) (str x)) (get words x) ;;rule 3,4 (seq rs) (clojure.string/join (map (partial get words) rs)) :else n))) @@ -23,4 +22,4 @@ (println "---------Begin of ouput---------") (doseq [n (range 1 101)] (println (say-what inputs words n))) (println "---------End of ouput---------"))) -
killme2008 created this gist
Apr 30, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ ;;Code for https://www.jinshuju.net/f/EGQL3D (defn- read-n-numbers [n] (repeatedly n #(let [x (read-line)] (Integer/valueOf x)))) (defn- say-what [inputs words n] (let [s (str n) [x y z] inputs rs (filter #(zero? (rem n %)) inputs)] (cond ;;rule 5 (.contains s (str x)) (get words x) ;;rule 3,4 (seq rs) (clojure.string/join (map (partial get words) rs)) :else n))) (defn- tw-test "Thoughtworks test." [] (let [inputs (read-n-numbers 3) words (zipmap inputs ["Fizz" "Buzz" "Whizz"])] (println "Inputs:" inputs) (println "---------Begin of ouput---------") (doseq [n (range 1 101)] (println (say-what inputs words n))) (println "---------End of ouput---------")))