Created
December 25, 2020 15:00
-
-
Save death/0cb82b19a0d8e493bb2e1568b25e6203 to your computer and use it in GitHub Desktop.
aoc2020 day25
This file contains hidden or 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
| ;;;; +----------------------------------------------------------------+ | |
| ;;;; | 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