June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,6 +1,19 @@
|
|||
(take 100
|
||||
(map #(str %1 %2 (if-not (or %1 %2) %3))
|
||||
(cycle [nil nil "Fizz"])
|
||||
(cycle [nil nil nil nil "Buzz"])
|
||||
(rest (range))
|
||||
))
|
||||
;;Using clojure maps
|
||||
(defn fizzbuzz
|
||||
[n]
|
||||
(let [rule {3 "Fizz"
|
||||
5 "Buzz"}
|
||||
divs (->> rule
|
||||
(map first)
|
||||
sort
|
||||
(filter (comp (partial = 0)
|
||||
(partial rem n))))]
|
||||
(if (empty? divs)
|
||||
(str n)
|
||||
(->> divs
|
||||
(map rule)
|
||||
(apply str)))))
|
||||
|
||||
(defn allfizzbuzz
|
||||
[max]
|
||||
(map fizzbuzz (range 1 (inc max))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue