From 3010d12259ff3d33c2920d2c4e4105256556d68a Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Sat, 20 Dec 2025 08:40:08 -0500 Subject: [PATCH] [p10] begin cleaning up the code --- p10/p10.org | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/p10/p10.org b/p10/p10.org index 8346974..45ba165 100644 --- a/p10/p10.org +++ b/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