|
|
|
|
@ -24,32 +24,30 @@ number of 0's mod 100; that is what we need for part 1 |
|
|
|
|
: 962 |
|
|
|
|
|
|
|
|
|
For part 2, This ain't pretty, but it works: |
|
|
|
|
- we count the number of full turns that have been done in each |
|
|
|
|
rotation |
|
|
|
|
- we add the number of times we landed at 0 by turning left and then |
|
|
|
|
right immediately after; these have not been counted above |
|
|
|
|
#+begin_src emacs-lisp |
|
|
|
|
(defun advent/consecutive-pairs (list) |
|
|
|
|
(-zip-pair list (cdr list))) |
|
|
|
|
|
|
|
|
|
(+ |
|
|
|
|
(-sum (--map (abs (- (car it) (cdr it))) |
|
|
|
|
(advent/consecutive-pairs |
|
|
|
|
(--map (floor it 100) (-running-sum (append '(50) data)))))) |
|
|
|
|
|
|
|
|
|
(length |
|
|
|
|
(--filter (and (eq (car it) 0) (< (cdr it) 0)) |
|
|
|
|
(-zip-pair |
|
|
|
|
(cdr (--map (mod it 100) (-running-sum (append '(50) data)))) |
|
|
|
|
data))) |
|
|
|
|
|
|
|
|
|
(* -1 (length |
|
|
|
|
(--filter (and (eq (car it) 0) (< (cdr it) 0)) |
|
|
|
|
(-zip-pair |
|
|
|
|
(cdr (--map (mod it 100) (-running-sum (append '(50) data)))) |
|
|
|
|
(cdr data)))))) |
|
|
|
|
(let ((number-list (-running-sum (append '(50) data)))) |
|
|
|
|
(+ |
|
|
|
|
(-sum (--map (abs (- (car it) (cdr it))) |
|
|
|
|
(advent/consecutive-pairs |
|
|
|
|
(--map (floor it 100) number-list)))) |
|
|
|
|
|
|
|
|
|
(length |
|
|
|
|
(--filter (and (eq (car it) 0) (< (cdr it) 0)) |
|
|
|
|
(-zip-pair |
|
|
|
|
(cdr (--map (mod it 100) number-list)) data))) |
|
|
|
|
|
|
|
|
|
(* -1 (length |
|
|
|
|
(--filter (and (eq (car it) 0) (< (cdr it) 0)) |
|
|
|
|
(-zip-pair |
|
|
|
|
(cdr (--map (mod it 100) number-list)) (cdr data))))))) |
|
|
|
|
#+end_src |
|
|
|
|
|
|
|
|
|
#+RESULTS: |
|
|
|
|
: 5782 |
|
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp |
|
|
|
|
(floor -5 100) |
|
|
|
|
#+end_src |
|
|
|
|
* |
|
|
|
|
|