src/2020/days/day-13.lisp @ 35ad1f73c754

Add scratch.md to .hgignore
author Steve Losh <steve@stevelosh.com>
date Wed, 08 Dec 2021 21:47:32 -0800
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 --------------------------------------------------------------------