Skip to content

Instantly share code, notes, and snippets.

@ampersanda
Created November 9, 2019 04:42
Show Gist options
  • Save ampersanda/3ceec241e71a2c336a298810bb913ecc to your computer and use it in GitHub Desktop.
Save ampersanda/3ceec241e71a2c336a298810bb913ecc to your computer and use it in GitHub Desktop.
Code Signal - Candles
(defn candles[c n]{:pre[(not(nil? c))(>= c 1)(<= c 15)(not (nil? n))(>= n 2)(<= n 5)]}(if(> n c)c(loop [r c b [c]](let[m (mod r n)f(int(double(/ r n)))](if(<= r n)(reduce + (flatten[b f]))(recur(+ m f)(conj b f)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment