14 lines
341 B
Fennel
14 lines
341 B
Fennel
(io.input "input")
|
|
|
|
(var calories [0])
|
|
|
|
(each [line (io.lines)]
|
|
(if (= line "") (table.insert calories 0)
|
|
(let [i (length calories)]
|
|
(tset calories i (+ (tonumber line) (. calories i))))))
|
|
|
|
(table.sort calories (λ [a b] (> a b)))
|
|
|
|
(print "part 1" (. calories 1))
|
|
(print "part 2" (let [c calories] (+ (. c 1) (. c 2) (. c 3))))
|