summaryrefslogtreecommitdiff
path: root/2020/aoc2020-d25.py
diff options
context:
space:
mode:
authorblenovo <bk@gmail.com>2025-08-06 00:51:06 +0200
committerblenovo <bk@gmail.com>2025-08-06 00:51:06 +0200
commit0a441ce2306ae9edefb009fbc0596f4d511cdc7f (patch)
tree11d5aca4383bbce8a35acb912698f473b8180215 /2020/aoc2020-d25.py
parent12f551dbfef138880b29ba6abe4576714ae942cb (diff)
summertime warmup session - finish
Diffstat (limited to '2020/aoc2020-d25.py')
-rw-r--r--2020/aoc2020-d25.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/2020/aoc2020-d25.py b/2020/aoc2020-d25.py
new file mode 100644
index 0000000..28d1afe
--- /dev/null
+++ b/2020/aoc2020-d25.py
@@ -0,0 +1,29 @@
+#advent of code 2020
+#day 25
+#I made a mistake by thinking that subject number is an unknow
+#while in reality it actually is =7 as in puzzle description
+
+def FindNumbers(pubkey):
+ S = 7;
+ L = 0;
+ v = 1;
+ while True:
+ L += 1;
+ v *= S;
+ v = v%20201227;
+ if v == pubkey:
+ return L; #gives loop number
+
+PuzzleInput = open("25.in","r").read().split("\n");
+cardkey = int(PuzzleInput[0]);
+doorkey = int(PuzzleInput[1]);
+#encryption key is the same
+#whether we use loop of card + subject of door
+#or loop of door + subject of card
+encryption = 1;
+for l in range(FindNumbers(cardkey)):
+ encryption *= doorkey;
+ encryption = encryption%20201227;
+
+part1 = encryption;
+print("part 1 =", part1);