Advent of Code 2020 Day 25

Author

Nathan Moore

Write the Puzzle explanation here

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.6
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.1     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.2.0     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
card <- 9033205
door <- 9281649
div <- 20201227

loop_max <- 1e8

tot <- 1
subj <- 7

Maybe write an explanation of the solution approach here

for (i in seq_len(loop_max)) {
  tot = tot * subj
  tot = tot %% div
  if (tot == card) card_loop = i
  if (tot == door) door_loop = i
}

enc_card <- 1
for (j in seq_len(card_loop)) {
  enc_card = enc_card * door
  enc_card = enc_card %% div
}

enc_door <- 1
for (j in seq_len(door_loop)) {
  enc_door = enc_door * card
  enc_door = enc_door %% div
}