a9a1535136c1dd908a04fb908279e84774d3b7f5 — Robert A. Uhl 10 months ago
Solve day 1
1 files changed, 1054 insertions(+), 0 deletions(-)

A 2018-12-01.lisp
A  => 2018-12-01.lisp +1054 -0
@@ 1,1054 @@
+ (defpackage "AOC/1" (:use "CL"))
+ (in-package "AOC/1")
+ 
+ ;; thanks to PuercoPop for sharing his format: http://code.puercopop.com/advent-of-code.git
+ 
+ (defconstant +input+ "+11
+ +14
+ +10
+ -8
+ -13
+ -2
+ +8
+ +14
+ -11
+ -4
+ +2
+ -17
+ -15
+ -12
+ -15
+ -16
+ -15
+ -13
+ -15
+ -4
+ -9
+ -4
+ -9
+ -12
+ +19
+ +1
+ +10
+ +15
+ -6
+ +15
+ +15
+ +19
+ -8
+ +16
+ +2
+ +12
+ +10
+ +20
+ -15
+ +16
+ -3
+ -2
+ +1
+ +8
+ +5
+ -6
+ +8
+ -22
+ -14
+ +13
+ -12
+ -6
+ +11
+ -1
+ +21
+ +11
+ +4
+ -6
+ -19
+ -27
+ -14
+ +8
+ -5
+ +1
+ -6
+ -16
+ -10
+ +13
+ -14
+ -4
+ -9
+ -5
+ +17
+ -4
+ -17
+ +2
+ +8
+ +14
+ +13
+ +5
+ +2
+ +3
+ -13
+ -18
+ -8
+ +12
+ +19
+ +14
+ -3
+ -15
+ +17
+ +14
+ -4
+ +1
+ +10
+ -13
+ +7
+ -21
+ +18
+ +4
+ +11
+ +7
+ +8
+ +14
+ +17
+ -6
+ +17
+ +7
+ +10
+ -14
+ +9
+ +15
+ +13
+ +6
+ +11
+ -8
+ +16
+ +18
+ -8
+ +6
+ +16
+ +1
+ +14
+ -1
+ -16
+ -6
+ +15
+ -4
+ +5
+ +9
+ +17
+ -18
+ +3
+ +14
+ -10
+ +21
+ -15
+ +14
+ +6
+ +18
+ -11
+ +4
+ -9
+ +17
+ +12
+ +15
+ +1
+ -17
+ +19
+ +3
+ +19
+ -14
+ -9
+ +7
+ +10
+ +3
+ +13
+ +2
+ -14
+ +16
+ +11
+ -3
+ +10
+ -13
+ +14
+ -2
+ -14
+ +18
+ -8
+ -19
+ +18
+ -6
+ +21
+ +4
+ +5
+ -4
+ +18
+ +16
+ -6
+ -18
+ -12
+ +17
+ -19
+ +13
+ +13
+ +9
+ +2
+ -3
+ +16
+ +2
+ -7
+ -6
+ +29
+ +14
+ +13
+ -1
+ +34
+ +19
+ -13
+ +23
+ +10
+ -2
+ -6
+ +10
+ -3
+ +18
+ -9
+ +2
+ +10
+ +17
+ -18
+ -14
+ +2
+ +6
+ -4
+ +12
+ -6
+ +11
+ +5
+ -7
+ +10
+ +4
+ +17
+ +15
+ -8
+ +7
+ -3
+ -2
+ +13
+ +22
+ +10
+ -16
+ +4
+ +15
+ -1
+ -3
+ +13
+ -8
+ -9
+ -3
+ +4
+ +5
+ +17
+ +10
+ +18
+ +11
+ +9
+ +1
+ +12
+ +11
+ +7
+ -8
+ -17
+ -19
+ +1
+ +9
+ -5
+ +19
+ -3
+ +17
+ +8
+ -23
+ -1
+ -4
+ -2
+ -17
+ -13
+ -14
+ +16
+ -18
+ -14
+ +12
+ +5
+ +4
+ -14
+ +22
+ -1
+ -15
+ +18
+ +10
+ -2
+ -13
+ -18
+ +2
+ -8
+ +3
+ -8
+ -17
+ -12
+ -8
+ +16
+ +6
+ +19
+ +39
+ +15
+ -19
+ -12
+ -4
+ +5
+ +17
+ +32
+ +4
+ -2
+ +15
+ -12
+ -41
+ +8
+ +18
+ -17
+ +24
+ +15
+ +13
+ +13
+ -14
+ +15
+ +14
+ -16
+ +4
+ -38
+ -59
+ -22
+ -35
+ +12
+ -8
+ -22
+ -14
+ +3
+ +6
+ -8
+ +5
+ -17
+ -18
+ -14
+ +10
+ +21
+ +8
+ -11
+ -4
+ +2
+ +9
+ +5
+ +14
+ +17
+ +7
+ +13
+ -23
+ -5
+ -13
+ +9
+ -18
+ -16
+ +17
+ +6
+ -3
+ -7
+ +26
+ -8
+ -48
+ -16
+ -2
+ -10
+ -21
+ +14
+ +9
+ -5
+ +8
+ -14
+ -3
+ -4
+ +3
+ -7
+ +10
+ -1
+ +12
+ +6
+ -13
+ +19
+ +9
+ +5
+ -29
+ +19
+ -6
+ -8
+ -21
+ -23
+ -25
+ -9
+ +5
+ +19
+ -2
+ -8
+ +100
+ +61
+ +1
+ +18
+ +108
+ -60
+ +291
+ -13
+ +118
+ -1098
+ -56117
+ +14
+ -15
+ -4
+ -2
+ -12
+ -18
+ +3
+ +5
+ +15
+ -10
+ +18
+ +12
+ -19
+ -7
+ -21
+ +16
+ -7
+ +15
+ +5
+ +3
+ -14
+ +7
+ +19
+ +10
+ +9
+ +12
+ +16
+ -10
+ -7
+ -2
+ +7
+ -18
+ -3
+ +11
+ +14
+ -17
+ -7
+ +6
+ -15
+ -11
+ +18
+ +14
+ -18
+ -7
+ +16
+ -6
+ -5
+ +22
+ +12
+ -8
+ +11
+ +5
+ +18
+ -5
+ -19
+ +8
+ +14
+ -19
+ +7
+ -3
+ -14
+ -4
+ -6
+ -6
+ +18
+ +7
+ +10
+ +23
+ -18
+ -8
+ +9
+ +8
+ +8
+ +4
+ +17
+ -16
+ +10
+ -9
+ -9
+ +17
+ -5
+ -10
+ +18
+ +9
+ +17
+ +12
+ -3
+ +13
+ +3
+ +16
+ -14
+ -1
+ -15
+ -4
+ +17
+ -4
+ +19
+ -4
+ +17
+ +20
+ +22
+ -43
+ +18
+ -9
+ +14
+ -12
+ -16
+ -16
+ -2
+ -11
+ +19
+ -13
+ +22
+ +2
+ +16
+ +17
+ -9
+ -23
+ +7
+ -6
+ +10
+ +20
+ +14
+ +3
+ -4
+ -48
+ -1
+ +14
+ -28
+ -16
+ -12
+ +4
+ +14
+ -20
+ -1
+ +4
+ -18
+ -17
+ +10
+ +14
+ +6
+ -2
+ +19
+ +4
+ +3
+ -27
+ -13
+ +8
+ -3
+ +2
+ +18
+ -30
+ +6
+ -22
+ +4
+ +11
+ +18
+ +17
+ -20
+ -17
+ +65
+ +20
+ +9
+ -6
+ -93
+ -22
+ +2
+ -10
+ -71
+ +17
+ -15
+ -10
+ -4
+ -6
+ -8
+ -14
+ -3
+ +13
+ -2
+ +12
+ -9
+ -12
+ +8
+ +47
+ -8
+ -23
+ -21
+ -23
+ -12
+ -8
+ -5
+ -17
+ -30
+ -25
+ -11
+ +6
+ -17
+ -13
+ +11
+ -14
+ -9
+ +17
+ +17
+ +10
+ -17
+ -8
+ -15
+ +2
+ +18
+ -6
+ -29
+ +1
+ -17
+ +19
+ +19
+ +22
+ +5
+ -1
+ +19
+ +13
+ +15
+ -5
+ -19
+ +6
+ -13
+ +15
+ +3
+ -23
+ -46
+ -16
+ -19
+ -16
+ -11
+ +4
+ -21
+ +16
+ +13
+ -20
+ -16
+ -1
+ -14
+ -6
+ -16
+ +9
+ -18
+ +19
+ +2
+ +15
+ +15
+ -16
+ -18
+ -15
+ +8
+ +6
+ -11
+ -11
+ -14
+ -18
+ +26
+ +15
+ -34
+ +17
+ -88
+ +1
+ -10
+ -8
+ +16
+ -10
+ -19
+ +10
+ -13
+ -10
+ -16
+ -16
+ +10
+ +16
+ +20
+ +15
+ -20
+ +12
+ -15
+ -10
+ -1
+ +7
+ +5
+ -16
+ -14
+ -18
+ +14
+ -1
+ -18
+ +16
+ -12
+ -5
+ +14
+ +12
+ +2
+ -10
+ -15
+ +10
+ -11
+ -5
+ -19
+ -4
+ +16
+ -18
+ +12
+ -3
+ -16
+ -2
+ +16
+ +16
+ -12
+ -14
+ -14
+ +5
+ +6
+ -20
+ +15
+ +14
+ -16
+ -17
+ -1
+ +10
+ -17
+ +6
+ -19
+ +12
+ -35
+ -10
+ +8
+ +111
+ +14
+ -11
+ -17
+ -11
+ -12
+ +1
+ +23
+ +15
+ +7
+ -8
+ +4
+ +24
+ -9
+ +19
+ +19
+ +13
+ -1
+ +3
+ +17
+ +5
+ -16
+ -17
+ -6
+ -5
+ +14
+ -24
+ +14
+ -12
+ -18
+ +1
+ +12
+ -16
+ +11
+ -5
+ +24
+ +15
+ +9
+ -17
+ +9
+ -8
+ +4
+ -16
+ -4
+ -14
+ -14
+ -12
+ -24
+ +9
+ -19
+ +159
+ -27
+ +11
+ +12
+ +11
+ +3
+ +16
+ -25
+ -23
+ +10
+ -24
+ +4
+ -70
+ -4
+ -32
+ -13
+ +103
+ +162
+ +41
+ -401
+ -56221
+ +8
+ +19
+ -3
+ -11
+ -6
+ -21
+ -7
+ +16
+ +4
+ -10
+ -8
+ -17
+ -10
+ +16
+ +8
+ +10
+ +10
+ +5
+ +12
+ +27
+ -2
+ -9
+ +12
+ -6
+ +13
+ +23
+ -54
+ -10
+ -4
+ +13
+ +21
+ -65
+ -14
+ +2
+ +13
+ -19
+ -11
+ +10
+ +10
+ -2
+ -4
+ +8
+ -15
+ -20
+ +2
+ -6
+ -11
+ -6
+ +7
+ +17
+ +13
+ +2
+ -7
+ -10
+ -18
+ -17
+ -16
+ +4
+ +4
+ +11
+ +8
+ +15
+ -8
+ +10
+ +20
+ -10
+ -17
+ +2
+ -19
+ +20
+ -17
+ +5
+ -2
+ -16
+ +14
+ -19
+ -15
+ +2
+ +17
+ -2
+ -11
+ -12
+ +7
+ -20
+ -19
+ +13
+ -17
+ +18
+ -17
+ +9
+ -2
+ +7
+ -6
+ +11
+ -9
+ +3
+ -19
+ -12
+ +15
+ +4
+ +10
+ +4
+ -11
+ +17
+ +19
+ +9
+ -19
+ +1
+ -19
+ +11
+ +21
+ -17
+ -9
+ +11
+ -3
+ +2
+ +8
+ +14
+ +18
+ -2
+ -1
+ -12
+ +10
+ -18
+ -8
+ -5
+ +14
+ +23
+ -7
+ -28
+ +18
+ +5
+ -19
+ +10
+ +16
+ +19
+ +13
+ +17
+ +14
+ +11
+ +7
+ +1
+ +5
+ -11
+ -3
+ +15
+ +4
+ -34
+ +8
+ +5
+ +7
+ -35
+ -9
+ -17
+ -5
+ +13
+ +11
+ +11
+ -12
+ -27
+ +1
+ +21
+ -2
+ +14
+ +3
+ +17
+ -6
+ +45
+ -16
+ +24
+ +91
+ +20
+ +23
+ -2
+ +9
+ +7
+ +12
+ +6
+ +9
+ +7
+ -12
+ -13
+ -15
+ -2
+ +14
+ -11
+ -4
+ -10
+ +17
+ -1
+ -14
+ +21
+ +11
+ +1
+ +13
+ -5
+ +14
+ +16
+ -10
+ +4
+ +17
+ +5
+ -1
+ -3
+ -7
+ -13
+ -7
+ -19
+ +6
+ +24
+ +5
+ -6
+ +9
+ -11
+ -14
+ +19
+ -15
+ +19
+ +12
+ +19
+ -1
+ -14
+ +2
+ -1
+ -16
+ +10
+ -5
+ -32
+ +13
+ -3
+ -15
+ +113294
+ ")
+ 
+ (format t "~&result: ~a~%" (with-input-from-string (s +input+) (loop for n = (read s nil) while n sum n)))
+ 
+ (format t "~&twice-visited: ~a"
+         (let ((deltas (coerce (with-input-from-string (s +input+) (loop for n = (read s nil) while n collect n)) 'vector)))
+           (loop with memo = (make-hash-table)
+                 for i from 0
+                 for n = (aref deltas (mod i (length deltas)))
+                 for freq = n then (+ freq n)
+                 until (gethash freq memo)
+                 do (setf (gethash freq memo) t)
+                 finally (return freq))))