-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay25.cs
37 lines (32 loc) · 899 Bytes
/
Day25.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Day25
{
public static void Main(string[] args)
{
List<string> puzzleInput = File.ReadLines("input.txt").ToList();
long cardPublicKey = long.Parse(puzzleInput[0]);
long doorPublicKey = long.Parse(puzzleInput[1]);
long cardLoopSize = 0;
long subjectNumber = 7;
long value = 1;
while (value != cardPublicKey)
{
value *= subjectNumber;
value %= 20201227;
cardLoopSize++;
}
subjectNumber = doorPublicKey;
value = 1;
for (int i = 0; i < cardLoopSize; i++)
{
value *= subjectNumber;
value %= 20201227;
}
Console.WriteLine($"Encryption Key: {value}");
}
}