From 0242a39a0659833610559504049811801b9f1b22 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Thu, 18 Sep 2025 22:27:53 -0400 Subject: [PATCH] progress in part2 --- p21/p21.org | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/p21/p21.org b/p21/p21.org index b2e5311..1c5dd6f 100644 --- a/p21/p21.org +++ b/p21/p21.org @@ -149,7 +149,7 @@ would blow in my face since we would have too many options to check. #+end_src #+RESULTS: -: 222670 +: 1972 The new idea would be to run things bottom-down. For a given pair of @@ -161,6 +161,17 @@ So we start from all possible combinations of keypad pairs #+begin_src emacs-lisp (setq direction-pairs (let ((directions (advent/split-string-into-char-list "<>^vA"))) (-mapcat (lambda (x) (--map (cons x it) directions)) directions))) + (setq basis-induction + (--map (cons it (connecting-paths (char-pairs-to-coordinate-pairs it dir-keypad-data) dir-keypad-data)) direction-pairs) + first-step (--map (cons (car it) (pick-shortest-string (cdr it))) basis-induction) ) + + (defun iterate-robot (s al) + (apply #'concat (--map (cdr (assoc it al)) (split-into-char-pairs (concat "A" s))))) + + (defun iterate-step (l) + (--map (cons (car it) (pick-shortest-string + (--map (iterate-robot it l) (cdr it)))) + basis-induction) + ) - (--map (connecting-paths (char-pairs-to-coordinate-pairs it dir-keypad-data) dir-keypad-data) direction-pairs) #+end_src