[p10] begin cleaning up the code

master
Jacopo De Simoi 3 months ago
parent 0475bc2b55
commit 3010d12259
  1. 12
      p10/p10.org

@ -1,7 +1,8 @@
#+title: Solution to p10
This problem is pretty hard. I have not yet completely understood the
linear algebra behind it.
This problem was quite hard. I think that probably I was hit hard by
the inefficiencies of elisp. Anyways. here it is:
#+begin_src emacs-lisp :results none
(with-temp-buffer
(insert-file-contents "input")
@ -26,7 +27,10 @@ For part 1 we do not need the last item This is a linear algebra
problem in characteristic 2; we are essentially bruteforcing the
vector space; we easily succeed.
For part 2, the same approach blows the stack even for the test input
For part 2, the same approach would blows the stack even for the test
input
#+begin_src emacs-lisp
(setq machines (--map (-rotate 1 (cdr it)) data))
@ -41,8 +45,6 @@ For part 2, the same approach blows the stack even for the test input
(if (= 0 (-sum (car machine))) (list machine)
(--map (cons it (cdr machine)) (--map (apply-button (car machine) it) (good-buttons machine)))))
machines ))
(-iterate 'solve-machines (list (car machines)) 19)
#+end_src
Instead, go depth first and memoize for the win… This works for the

Loading…
Cancel
Save