Skip to content

Instantly share code, notes, and snippets.

@zelark
Last active October 16, 2024 12:00
Show Gist options
  • 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