|
|
|
@ -19,3 +19,16 @@ |
|
|
|
"Split the string into a list of chars" |
|
|
|
"Split the string into a list of chars" |
|
|
|
(--map (string-to-char it) (split-string str "\\|.+" t))) |
|
|
|
(--map (string-to-char it) (split-string str "\\|.+" t))) |
|
|
|
#+end_src |
|
|
|
#+end_src |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp |
|
|
|
|
|
|
|
(defun advent/coordinates-of (e li) |
|
|
|
|
|
|
|
"This takes a 2D list (a list of lists) of chars LI and an element E |
|
|
|
|
|
|
|
and returns a list of positions in LI that contain the element E. |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
(-map #'cadr |
|
|
|
|
|
|
|
(--filter (eq (car it) e) |
|
|
|
|
|
|
|
(-mapcat #'identity |
|
|
|
|
|
|
|
(-map-indexed (lambda (y l) |
|
|
|
|
|
|
|
(-map-indexed (lambda (x el) (list el (list x y))) l)) |
|
|
|
|
|
|
|
li))))) |
|
|
|
|
|
|
|
#+end_src |
|
|
|
|