diff --git a/AOC.Test/Test2015.cs b/AOC.Test/Test2015.cs index 640e519..1fec09c 100644 --- a/AOC.Test/Test2015.cs +++ b/AOC.Test/Test2015.cs @@ -28,6 +28,7 @@ public class Test2015 [DataRow(typeof(Day20), "665280", "705600")] [DataRow(typeof(Day21), "78", "148")] [DataRow(typeof(Day23), "255", "334")] + [DataRow(typeof(Day25), "9132360", "")] public void CheckAllDays(Type dayType, string part1, string part2) { Common.CheckDay(dayType, part1, part2); diff --git a/AOC2015/Day25.cs b/AOC2015/Day25.cs index 54785b8..671f102 100644 --- a/AOC2015/Day25.cs +++ b/AOC2015/Day25.cs @@ -3,13 +3,28 @@ namespace AOC2015; /// /// Day 25: /// -public sealed class Day25() : Day(2015, 25, "Let It Snow") +public sealed partial class Day25() : Day(2015, 25, "Let It Snow") { + [GeneratedRegex(@"\d+")] + private static partial Regex NumbersRegex(); + + private int _row, _col; + public override void ProcessInput() { + var s = NumbersRegex().Matches(Input.First()).Select(m => int.Parse(m.Value)).ToList(); + _row = s[0]; + _col = s[1]; } - public override object Part1() => ""; + public override object Part1() + { + var index = _row + _col - 2; + index = index * (index + 1) / 2 + _col - 1; + + return Enumerable.Range(0, index) + .Aggregate(20151125ul, (current, _) => current * 252533 % 33554393); + } public override object Part2() => ""; }