parent
caff3298d2
commit
04e2349bd0
1 changed files with 42 additions and 0 deletions
@ -0,0 +1,42 @@ |
||||
#+title: Solution to p22 |
||||
|
||||
#+begin_src emacs-lisp :results none |
||||
(require 'dash) |
||||
(with-temp-buffer |
||||
(insert-file-contents "input") |
||||
(goto-char (point-min)) |
||||
(insert "(setq data '(") |
||||
(goto-char (point-max)) |
||||
(insert "))") |
||||
(eval-buffer)) |
||||
#+end_src |
||||
|
||||
#+begin_src emacs-lisp :results none |
||||
(defun mix (a b) |
||||
(logxor a b)) |
||||
|
||||
(defun prune (a) |
||||
(logand a 16777215)) |
||||
|
||||
(defun pseudo-next-1 (a) |
||||
(prune (mix a (ash a 6)))) |
||||
|
||||
(defun pseudo-next-2 (a) |
||||
(prune (mix a (ash a -5)))) |
||||
|
||||
(defun pseudo-next-3 (a) |
||||
(prune (mix a (ash a 11)))) |
||||
|
||||
(defun pseudo-next (a) |
||||
(pseudo-next-3 |
||||
(pseudo-next-2 |
||||
(pseudo-next-1 a))) |
||||
) |
||||
#+end_src |
||||
|
||||
#+begin_src emacs-lisp |
||||
(apply #'+ (--map (-last-item (-iterate 'pseudo-next it 2001)) data)) |
||||
#+end_src |
||||
|
||||
#+RESULTS: |
||||
: 19241711734 |
||||
Loading…
Reference in new issue