From 4901abde40a67d4c7844569bc896d9330d863324 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Fri, 2 Dec 2022 17:31:38 +0100 Subject: alternative reading letting it crash --- AoC2022/02/solver.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'AoC2022/02') diff --git a/AoC2022/02/solver.el b/AoC2022/02/solver.el index 62dd554..66fa308 100644 --- a/AoC2022/02/solver.el +++ b/AoC2022/02/solver.el @@ -9,7 +9,7 @@ ;; Version: 0.0.1 ;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp ;; Homepage: https://github.com/titan/solver -;; Package-Requires: ((emacs "25.1")) +;; Package-Requires: ((emacs "27.1")) ;; ;; This file is not part of GNU Emacs. ;; @@ -71,10 +71,21 @@ (with-temp-buffer (insert-file-contents "input") (goto-char 0) + ;; Equivalent forms to incrementally read. + ;; Probe end of file (cl-loop while (not (looking-at (rx (* whitespace) eot))) for oponent = (solver-translate (read (current-buffer))) for my-game = (funcall strategy oponent (read (current-buffer))) - sum (+ (solver-weight my-game) (solver-result-a my-game oponent))))) + sum (+ (solver-weight my-game) (solver-result-a my-game oponent))) + ;; Let it crash and recover last + ;; (let ((total 0)) + ;; (ignore-error end-of-file + ;; (while t + ;; (let* ((oponent (solver-translate (read (current-buffer)))) + ;; (my-game (funcall strategy oponent (read (current-buffer))))) + ;; (cl-incf total (+ (solver-weight my-game) (solver-result-a my-game oponent)))))) + ;; total) + )) (ert-deftest solver-results () (should (= 12535 (solver-parse #'solver-fixed-plays))) -- cgit v1.2.3