some progress on p10

main
Jacopo De Simoi 11 months ago
parent a12e11092e
commit 5b909db4f4
  1. 39
      p10/p10.org

@ -16,16 +16,35 @@ Load the file into a list of lines
#+end_src
and split into a list of list of chars
#+begin_src emacs-lisp
(setq data-chars (-map (lambda (str) (-map #'string-to-char (split-string str "\\|.+" t)))
data))
(setq data-chars (-map (lambda (str) (--map (- (string-to-char it) ?0) (split-string str "\\|.+" t)))
data))
#+end_src
#+RESULTS:
| 56 | 57 | 48 | 49 | 48 | 49 | 50 | 51 |
| 55 | 56 | 49 | 50 | 49 | 56 | 55 | 52 |
| 56 | 55 | 52 | 51 | 48 | 57 | 54 | 53 |
| 57 | 54 | 53 | 52 | 57 | 56 | 55 | 52 |
| 52 | 53 | 54 | 55 | 56 | 57 | 48 | 51 |
| 51 | 50 | 48 | 49 | 57 | 48 | 49 | 50 |
| 48 | 49 | 51 | 50 | 57 | 56 | 48 | 49 |
| 49 | 48 | 52 | 53 | 54 | 55 | 51 | 50 |
| 8 | 9 | 0 | 1 | 0 | 1 | 2 | 3 |
| 7 | 8 | 1 | 2 | 1 | 8 | 7 | 4 |
| 8 | 7 | 4 | 3 | 0 | 9 | 6 | 5 |
| 9 | 6 | 5 | 4 | 9 | 8 | 7 | 4 |
| 4 | 5 | 6 | 7 | 8 | 9 | 0 | 3 |
| 3 | 2 | 0 | 1 | 9 | 0 | 1 | 2 |
| 0 | 1 | 3 | 2 | 9 | 8 | 0 | 1 |
| 1 | 0 | 4 | 5 | 6 | 7 | 3 | 2 |
this yields the coordinates of the 0s
#+begin_src emacs-lisp
(-map #'cadr
(--filter (eq (car it) 0)
(-mapcat #'identity
(-map-indexed (lambda (y l) (-map-indexed (lambda (x el) (list el (list x y))) l)) data-chars))))
#+end_src
#+RESULTS:
| 2 | 0 |
| 4 | 0 |
| 4 | 2 |
| 6 | 4 |
| 2 | 5 |
| 5 | 5 |
| 0 | 6 |
| 6 | 6 |
| 1 | 7 |

Loading…
Cancel
Save