Created
May 14, 2010 07:02
-
-
Save LauJensen/400896 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 knapsack_count | |
[sack space] | |
(if (or (empty? sack) (< space 0)) | |
0 | |
(if (= space 0) | |
1 | |
(+ | |
(knapsack_count (next sack) space) | |
(knapsack_count sack (- space (first sack))))))) | |
(println (knapsack_count [1 2 5 10 20 50 100 200] 200)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment