-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day22Solver.cs
44 lines (32 loc) · 1.09 KB
/
Day22Solver.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
38
39
40
41
42
43
44
using AdventOfCode.Abstractions;
namespace AdventOfCode.Year2019.Day22;
/// <summary>
/// https://www.reddit.com/r/adventofcode/comments/ee0rqi/comment/fbnkaju/
/// </summary>
public class Day22Solver : DaySolver
{
public Day22Solver(string inputFilePath) : base(inputFilePath)
{
}
public override string SolvePart1()
{
const int NumberOfCards = 10007;
const int CardToFind = 2019;
var shuffler = new SimpleCardShuffler(NumberOfCards);
var interpreter = new ShuffleInstructionInterpreter(InputLines);
interpreter.ExecuteInstructionsOn(shuffler);
long cardIndex = shuffler.GetCardIndex(CardToFind);
return cardIndex.ToString();
}
public override string SolvePart2()
{
const long NumberOfCards = 119315717514047;
const int CardToFind = 2020;
const long NumberOfShuffles = 101741582076661;
var shuffler = new SequenceFingerprintCardShuffler(NumberOfCards);
var interpreter = new ShuffleInstructionInterpreter(InputLines);
interpreter.ExecuteInstructionsOn(shuffler);
long cardIndex = shuffler.GetCardIndex(CardToFind, NumberOfShuffles);
return cardIndex.ToString();
}
}