Skip to content

Instantly share code, notes, and snippets.

@death
Created December 25, 2020 15:00
Show Gist options
  • Select an option

  • Save death/0cb82b19a0d8e493bb2e1568b25e6203 to your computer and use it in GitHub Desktop.

Select an option

Save death/0cb82b19a0d8e493bb2e1568b25e6203 to your computer and use it in GitHub Desktop.
aoc2020 day25
;;;; +----------------------------------------------------------------+
;;;; | Advent of Code 2020 |
;;;; +----------------------------------------------------------------+
(defpackage #:snippets/aoc2020/day25
(:use #:cl)
(:import-from
#:ironclad
#:expt-mod)
(:export
#:day25))
(in-package #:snippets/aoc2020/day25)
(defun day25 (input)
(destructuring-bind (a b) input
(let* ((m 20201227)
(d2 (dotimes (d m)
(let ((v (expt-mod 7 d m)))
(when (= v b)
(return d))))))
(list (expt-mod a d2 m)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment