src/2019/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/2019/01)
(in-package :advent/2019/01)


(defun fuel-required (module-mass)
  (max 0 (- (floor module-mass 3) 2)))

(defun complete-fuel-required (module-mass)
  (iterate
    (for fuel :first (fuel-required module-mass) :then (fuel-required fuel))
    (summing fuel)
    (until (zerop fuel))))

(define-problem (2019 1) (data read-all) (3464458 5193796)
  (values (summation data :key #'fuel-required)
          (summation data :key #'complete-fuel-required)))

;# Scratch --------------------------------------------------------------------

;; (run)
;; (1am:run)