src/2020/days/day-13.lisp @ 2848a4548adf
2023/01 and 2022/01
Also start porting my test data to the new account, since Twitter imploded and
apparently it's impossible for a website to store a goddamn username and
password in The Year of Our Lord 2023 so everyone just outsources auth all
the time, ugh.
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 01 Dec 2023 11:05:43 -0500 |
parents |
0b68f84e44ae |
children |
(none) |
(advent:defpackage* :advent/2020/13)
(in-package :advent/2020/13)
(defun parse (stream)
(cons (parse-integer (read-line stream))
(_ (read-line stream)
(str:split "," _)
(remove "x" _ :test #'string=)
(mapcar #'parse-integer _))))
(defun part1 (n buses)
(iterate (for b :in buses)
(for wait = (- (mod n (- b))))
(finding (* b wait) :minimizing wait)))
(define-problem (2020 13) (data parse) (174)
(destructuring-bind (n . buses) data
(values (part1 n buses))))
#; Scratch --------------------------------------------------------------------