-
-
Save cgrand/199482c74eb8034c147c to your computer and use it in GitHub Desktop.
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 change | |
([n] (change n [:baz 21 :qix 11 :bar 7 :foo 1])) | |
([n us] | |
(if-let [[nu vu & us] (seq us)] | |
(concat (for [mu (range vu (inc n) vu) | |
m (change (- n mu) us)] | |
(assoc m nu (/ mu vu))) | |
(change n us)) | |
(when (zero? n) [{}])))) |
Tu peux virer le concat et faire démarrer l range à zéro, non?
Ah c'est pour ne pas inscrire des :xxx 0 ok
On pourrait comme dans ma version améliorer le bottom case en le considérant lorsqu'il n'y à plus qu'un type de pièce possible: et c'est alors uniquement si le reminder est à zéro qu'on retourne le quotient entier, sinon liste vide ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bravo ! ☺