aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2022-12-02 17:31:38 +0100
committerOscar Najera <hi@oscarnajera.com>2022-12-02 17:31:38 +0100
commit4901abde40a67d4c7844569bc896d9330d863324 (patch)
tree9197a56845442d9d37d3fa98ba912931d9783f9e
parent9c836851537dfbabcbcbc7b0384c9f4b81d36a85 (diff)
downloadscratch-4901abde40a67d4c7844569bc896d9330d863324.tar.gz
scratch-4901abde40a67d4c7844569bc896d9330d863324.tar.bz2
scratch-4901abde40a67d4c7844569bc896d9330d863324.zip
alternative reading letting it crash
-rw-r--r--AoC2022/02/solver.el15
1 files changed, 13 insertions, 2 deletions
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)))