Last active
December 15, 2017 05:57
-
-
Save PuercoPop/725864d615b47efb3a5e494daa527981 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun next (prev factor) | |
(rem (* prev factor) 2147483647)) | |
(defun solve/2 (limit initial-a initial-b) | |
(let ((gen-a initial-a) | |
(gen-b initial-b) | |
(match-count 0) | |
(success-count 0)) | |
(tagbody | |
next-a | |
(setf gen-a (next gen-a 16807)) | |
(unless (zerop (mod gen-a 4)) | |
(go next-a)) | |
next-b | |
(setf gen-b (next gen-b 48271)) | |
(unless (zerop (mod gen-b 8)) | |
(go next-b)) | |
compare | |
(incf match-count) | |
(when (= (ldb (byte 16 0) gen-a) | |
(ldb (byte 16 0) gen-b)) | |
(incf success-count)) | |
(unless (= match-count limit) | |
(go next-a))) | |
success-count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment