day 25 part 1
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
219c1eec72
commit
b94a8bb120
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue