Created
November 9, 2019 04:42
-
-
Save ampersanda/3ceec241e71a2c336a298810bb913ecc to your computer and use it in GitHub Desktop.
Code Signal - Candles
This file contains 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 characters
(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