2017-7/1
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 01 Dec 2018 17:00:00 -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))))