Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Last active December 15, 2017 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PuercoPop/725864d615b47efb3a5e494daa527981 to your computer and use it in GitHub Desktop.
Save PuercoPop/725864d615b47efb3a5e494daa527981 to your computer and use it in GitHub Desktop.
(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