Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/McNuggets-problem/Clojure/mcnuggets-problem.clj
Normal file
12
Task/McNuggets-problem/Clojure/mcnuggets-problem.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(defn cart [colls]
|
||||
(if (empty? colls)
|
||||
'(())
|
||||
(for [more (cart (rest colls))
|
||||
x (first colls)]
|
||||
(cons x more))))
|
||||
|
||||
(defn nuggets [[n6 n9 n20]] (+ (* 6 n6) (* 9 n9) (* 20 n20)))
|
||||
|
||||
(let [possible (distinct (map nuggets (cart (map range [18 13 6]))))
|
||||
mcmax (apply max (filter (fn [x] (not-any? #{x} possible)) (range 101)))]
|
||||
(printf "Maximum non-McNuggets number is %d\n" mcmax))
|
||||
Loading…
Add table
Add a link
Reference in a new issue