-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0017.clj
More file actions
executable file
·21 lines (19 loc) · 856 Bytes
/
0017.clj
File metadata and controls
executable file
·21 lines (19 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(def solutions (list (fn []
(let [ones (map count '("one" "two" "three" "four" "five" "six" "seven" "eight" "nine"))
teens (map count '("ten" "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" "seventeen" "eighteen" "nineteen"))
tens (map count '("twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety"))
to99 (+
(apply + ones)
(apply + teens)
(apply + (map (fn [t] (apply + (cons t (map (fn [o] (+ t o))
ones)))) tens)))
hundreds (map #(+ (count "hundred") %) ones)
soln (+ to99
(apply + hundreds)
(apply + (map (fn [h]
(+ to99 (* 99
(+ h 3)))) hundreds)))
soln (+ soln (count "onethousand"))
]
soln)
)))