|
|
|
|
@ -208,38 +208,6 @@ These are some auxiliary functions to create and deal with matrices |
|
|
|
|
#+RESULTS: |
|
|
|
|
| 19 | 16 | 12 | 11 | 0 | 8 | 14 | 3 | 8 | |
|
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp |
|
|
|
|
(setq rainbow (-annotate (lambda (n) (--map (mod n it) '(2 3 5 7))) (-iota (* 2 3 5 7)))) |
|
|
|
|
|
|
|
|
|
(-sum |
|
|
|
|
(let ((machine-id 0)) |
|
|
|
|
(-each machines (lambda (machine) |
|
|
|
|
(let* ((matrix (-distinct (matrix-buttons (fix-machine machine)))) |
|
|
|
|
(solmod (--map (solve-well-ordered-chunks-mod matrix it) '(2 3 5 7))) |
|
|
|
|
(solns nil) |
|
|
|
|
(numcand (apply '* (-map 'length solmod))) |
|
|
|
|
(count 0)) |
|
|
|
|
;; Oh Programming Gods, have mercy of me for I have sinned |
|
|
|
|
(-each (car solmod) |
|
|
|
|
(lambda (a) |
|
|
|
|
(-each (cadr solmod) |
|
|
|
|
(lambda (b) |
|
|
|
|
(-each (caddr solmod) |
|
|
|
|
(lambda (c) |
|
|
|
|
(-each (cadddr solmod) |
|
|
|
|
(lambda (d) |
|
|
|
|
(let ((cand (--map (cdr (assoc it rainbow)) (-zip-lists a b c d)))) |
|
|
|
|
(message (format "machine %d. Verifying %d / %d - found %d" machine-id (setq count (1+ count)) numcand (length solns))) |
|
|
|
|
(when (test-soln matrix cand) (push cand solns))))))))))) |
|
|
|
|
(setq machine-id (1+ machine-id)) |
|
|
|
|
(-min (-map '-sum solns)) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
)) |
|
|
|
|
) |
|
|
|
|
#+end_src |
|
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp |
|
|
|
|
(setq rainbow (-annotate (lambda (n) (--map (mod n it) '(2 3 5 7))) (-iota (* 2 3 5 7)))) |
|
|
|
|
@ -276,7 +244,7 @@ These are some auxiliary functions to create and deal with matrices |
|
|
|
|
#+end_src |
|
|
|
|
|
|
|
|
|
#+RESULTS: |
|
|
|
|
: 33 |
|
|
|
|
: 16474 |
|
|
|
|
|
|
|
|
|
#+RESULTS: |
|
|
|
|
(process-machine (nth 51 machines)) |
|
|
|
|
@ -631,7 +599,7 @@ try to split into chunks |
|
|
|
|
#+end_src |
|
|
|
|
|
|
|
|
|
#+RESULTS: |
|
|
|
|
: solve-well-ordered-chunks |
|
|
|
|
: solve-well-ordered-chunks-mod |
|
|
|
|
|
|
|
|
|
Try to do it recursively |
|
|
|
|
#+begin_src emacs-lisp |
|
|
|
|
|