aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/01/solver.el
blob: da7682d74db069d99f9d89cb3f108c9ee37f04da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
;;; solver.el --- Solution for AoC 2022 day 1 -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2022 Óscar Nájera
;;
;; Author: Óscar Nájera <hi@oscarnajera.com>
;; Maintainer: Óscar Nájera <hi@oscarnajera.com>
;; Created: December 02, 2022
;; Modified: December 02, 2022
;; Version: 0.0.1
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp
;; Homepage: https://github.com/titan/solver
;; Package-Requires: ((emacs "25.1"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;;  Solution for AoC 2022 day 1
;;
;;; Code:
(require 'seq)

;; calculate the maximum from each elves rations
(with-temp-buffer
  (insert-file-contents "input")
  (apply #'max
         (mapcar
          (lambda (elf)
            (seq-reduce (lambda (acc x)
                          (+ acc (string-to-number x)))
                        (split-string elf) 0))
          (split-string (buffer-string) "\n\n"))))

(provide 'solver)
;;; solver.el ends here