parent
6bd2a4f48c
commit
4c6a711b39
1 changed files with 29 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||||||
|
#+title: Solution to p6 |
||||||
|
|
||||||
|
First load the data as a list of cons cells (start . end) |
||||||
|
#+begin_src emacs-lisp :results none |
||||||
|
(with-temp-buffer |
||||||
|
(insert-file-contents "input") |
||||||
|
(advent/replace-multiple-regex-buffer |
||||||
|
'( |
||||||
|
("^" . "(") |
||||||
|
("$" . ")") |
||||||
|
)) |
||||||
|
(goto-char (point-min)) |
||||||
|
(insert "(setq data '(") |
||||||
|
(goto-char (point-max)) |
||||||
|
(insert "))") |
||||||
|
(eval-buffer)) |
||||||
|
#+end_src |
||||||
|
|
||||||
|
This is for part 1. Quite straightforward |
||||||
|
#+begin_src emacs-lisp |
||||||
|
(-sum (--map (apply (car it) (cdr it)) |
||||||
|
(apply #'-zip-lists (-rotate 1 data)))) |
||||||
|
#+end_src |
||||||
|
|
||||||
|
#+begin_src emacs-lisp |
||||||
|
|
||||||
|
#+end_src |
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in new issue