|
|
|
@ -17,12 +17,16 @@ First load the data as a list of cons cells (start . end) |
|
|
|
|
|
|
|
|
|
|
|
This is for part 1 |
|
|
|
This is for part 1 |
|
|
|
#+begin_src emacs-lisp |
|
|
|
#+begin_src emacs-lisp |
|
|
|
(length |
|
|
|
(-count (lambda (id) |
|
|
|
(-filter (lambda (id) |
|
|
|
|
|
|
|
(--any (and (>= id (car it)) |
|
|
|
(--any (and (>= id (car it)) |
|
|
|
(<= id (cdr it))) |
|
|
|
(<= id (cdr it))) |
|
|
|
|
|
|
|
ranges)) |
|
|
|
|
|
|
|
ids) |
|
|
|
#+end_src |
|
|
|
#+end_src |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#+RESULTS: |
|
|
|
|
|
|
|
: 744 |
|
|
|
|
|
|
|
|
|
|
|
For part 2, sort and merge the ranges (when they are overlapping or |
|
|
|
For part 2, sort and merge the ranges (when they are overlapping or |
|
|
|
adjacent), then sum their lengths |
|
|
|
adjacent), then sum their lengths |
|
|
|
#+begin_src emacs-lisp |
|
|
|
#+begin_src emacs-lisp |
|
|
|
|