day 25 part 1
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Ben Harris 2021-11-28 15:08:11 -05:00
parent 219c1eec72
commit b94a8bb120
Signed by: ben
GPG Key ID: 4E0AF802FFF7960C
2 changed files with 30 additions and 2 deletions

View File

@ -31,7 +31,7 @@ public class DayTests
[DataRow(typeof(Day22), "32856", "33805")]
[DataRow(typeof(Day23), "36542897", "562136730660")]
[DataRow(typeof(Day24), "282", "3445")]
//[DataRow(typeof(Day25), "", "")]
[DataRow(typeof(Day25), "11707042", "")]
public void CheckAllDays(Type dayType, string part1, string part2)
{
// create day instance

View File

@ -9,7 +9,35 @@ public sealed class Day25 : Day
{
}
public override string Part1() => "";
public override string Part1()
{
var cardKey = int.Parse(Input.First());
var doorKey = int.Parse(Input.Last());
return $"{Transform(doorKey, FindLoopSize(7, cardKey))}";
}
public override string Part2() => "";
private static long Transform(long subject, int loopSize)
{
var value = 1L;
for (var i = 0; i < loopSize; i++)
{
value *= subject;
value %= 20201227;
}
return value;
}
private static int FindLoopSize(long subject, int target)
{
var value = 1L;
var loops = 0;
while (value != target)
{
value *= subject;
value %= 20201227;
loops++;
}
return loops;
}
}