aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022
diff options
context:
space:
mode:
Diffstat (limited to 'AoC2022')
-rw-r--r--AoC2022/01/solver.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/AoC2022/01/solver.el b/AoC2022/01/solver.el
index da7682d..67c1980 100644
--- a/AoC2022/01/solver.el
+++ b/AoC2022/01/solver.el
@@ -31,5 +31,18 @@
(split-string elf) 0))
(split-string (buffer-string) "\n\n"))))
+;; calculate the maximum from each elves rations
+(with-temp-buffer
+ (insert-file-contents "input")
+ (apply #'+
+ (thread-first
+ (mapcar
+ (lambda (elf)
+ (seq-reduce (lambda (acc x)
+ (+ acc (string-to-number x)))
+ (split-string elf) 0))
+ (split-string (buffer-string) "\n\n"))
+ (sort #'>)
+ (seq-take 3))))
(provide 'solver)
;;; solver.el ends here