diff options
author | Oscar Najera <hi@oscarnajera.com> | 2022-12-02 13:48:50 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2022-12-02 13:48:50 +0100 |
commit | 400b581731c25975660b86c57f89463b63c59d38 (patch) | |
tree | 1e5f111c65eb705eac9fbb5685850994021892d8 /AoC2022/01 | |
parent | 38874a4973f3cb9eb7908d2e332dde3af5b28a94 (diff) | |
download | scratch-400b581731c25975660b86c57f89463b63c59d38.tar.gz scratch-400b581731c25975660b86c57f89463b63c59d38.tar.bz2 scratch-400b581731c25975660b86c57f89463b63c59d38.zip |
[AoC2022] 01-02
Diffstat (limited to 'AoC2022/01')
-rw-r--r-- | AoC2022/01/solver.el | 13 |
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 |