Emacs lisp solution for day one of advent of code 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun cals-per-elf () | |
(with-temp-buffer | |
(progn (insert "((") | |
(insert-file-contents "~/res.txt") | |
(while (re-search-forward "^$" nil t) | |
(replace-match ")(" nil nil)) | |
(end-of-buffer)(insert "))") | |
(goto-char 0)) | |
(mapcar (lambda (food-carried) | |
(cl-reduce #'+ food-carried)) | |
(read (current-buffer))))) | |
(defun aoc-day1-part1 () | |
(cl-reduce #'max | |
(cals-per-elf))) | |
(defun aoc-day1-part1 () | |
(cl-reduce #'+ | |
(seq-take (cl-sort (cals-per-elf) | |
#'>) | |
3))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment