src/2018/main.lisp @ 66e86b59fc60

Minor cleanup
author Steve Losh <steve@stevelosh.com>
date Sat, 01 Dec 2018 19:30:27 -0500
parents 388494359561
children e22f6a54b6d5
(in-package :advent)

;;;; Problems -----------------------------------------------------------------
(define-problem (2018 1 1) (data read-all-from-file)
  (summation data))

(define-problem (2018 1 2) (data read-all-from-file)
  (setf (cdr (last data)) data) ; make data a circular list for easy looping
  (iterate
    (with seen = (make-hash-set :initial-contents '(0)))
    (for number :in data)
    (summing number :into frequency)
    (if (hset-contains-p seen frequency)
      (return frequency)
      (hset-insert! seen frequency))))