Skip to content

Instantly share code, notes, and snippets.

@zelark
Last active October 7, 2020 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zelark/a766274986d6212a8f85d7aa4c6d1179 to your computer and use it in GitHub Desktop.
Save zelark/a766274986d6212a8f85d7aa4c6d1179 to your computer and use it in GitHub Desktop.
#fizzbuzz
(defn fizzbuzz [n]
(let [fizzes (cycle ["" "" "Fizz"])
buzzes (cycle ["" "" "" "" "Buzz"])
pattern (map str fizzes buzzes)
numbers (map str (rest (range)))]
(take n (map #(some not-empty %&) pattern numbers)))) ;; another option would be `(partial max-key count)`
(run! println (fizzbuzz 100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment