Using org-mode and Emacs Lisp to solve Advent of Code.
(org-babel-lob-ingest "./library-of-babel.org")
Read the CSV
"1-1.txt"
(require 'cl-lib)
(defun laat/aoc-1-1 (xs)
(apply '* (cl-intersection (mapcar (lambda (arg) (- 2020 arg)) xs) xs)))
(laat/aoc-1-1 (mapcar 'string-to-number (mapcar 'car example)))
Read the CSV, it’s the same as 1-1.
"1-1.txt"
(require 'cl-lib)
(defun laat/aoc-1-2 (xs)
(apply '* (car
(cl-remove-if
(lambda (x) (not (equal (apply '+ x) 2020)))
(mapcan
(lambda (a)
(mapcan
(lambda (b)
(mapcar
(lambda (c) (list a b c)) xs)) xs)) xs)))))
(laat/aoc-1-2 (mapcar 'string-to-number (mapcar 'car example)))