src/2017/days/day-01.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 182bdd87fd9e
children (none)
(advent:defpackage* :advent/2017/01)
(in-package :advent/2017/01)


(define-problem (2017 1) (data read-line) (1049 1508)
  (iterate
    (with digits = (map 'vector #'digit-char-p data))
    (for digit :in-vector digits)
    (for prev :previous digit :initially (aref digits (1- (length digits))))
    (for j :modulo (length digits) :from (truncate (length digits) 2))
    (for next = (aref digits j))
    (when (= digit prev) (sum digit :into part1))
    (when (= digit next) (sum digit :into part2))
    (finally (return (values part1 part2)))))