ben
/
aoc
1
0
Fork 0

2015 day 10
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Ben Harris 2022-11-13 14:51:53 -05:00
parent 96bfa4296f
commit 2de2266e18
3 changed files with 44 additions and 3 deletions

View File

@ -15,6 +15,7 @@ public class Test2015
[DataRow(typeof(Day07), "3176", "14710")] [DataRow(typeof(Day07), "3176", "14710")]
[DataRow(typeof(Day08), "1342", "2074")] [DataRow(typeof(Day08), "1342", "2074")]
[DataRow(typeof(Day09), "117", "909")] [DataRow(typeof(Day09), "117", "909")]
[DataRow(typeof(Day10), "492982", "6989950")]
public void TestAllDays(Type dayType, string part1, string part2) public void TestAllDays(Type dayType, string part1, string part2)
{ {
Common.CheckDay(dayType, part1, part2); Common.CheckDay(dayType, part1, part2);
@ -30,6 +31,7 @@ public class Test2015
// [DataRow(typeof(Day07), "", "")] // test input doesn't have "a" wire // [DataRow(typeof(Day07), "", "")] // test input doesn't have "a" wire
[DataRow(typeof(Day08), "12", "19")] [DataRow(typeof(Day08), "12", "19")]
[DataRow(typeof(Day09), "605", "982")] [DataRow(typeof(Day09), "605", "982")]
[DataRow(typeof(Day10), "237746", "3369156")]
public void CheckTestInputs(Type dayType, string part1, string part2) public void CheckTestInputs(Type dayType, string part1, string part2)
{ {
Day.UseTestInput = true; Day.UseTestInput = true;

View File

@ -5,11 +5,49 @@
/// </summary> /// </summary>
public sealed class Day10 : Day public sealed class Day10 : Day
{ {
private string _seed;
public Day10() : base(2015, 10, "Puzzle Name") public Day10() : base(2015, 10, "Puzzle Name")
{ {
_seed = Input.First();
} }
public override object Part1() => ""; public override object Part1()
{
for (var i = 0; i < 40; i++)
_seed = string.Concat(LookAndSay(_seed));
public override object Part2() => ""; return _seed.Length;
} }
public override object Part2()
{
for (var i = 0; i < 10; i++)
_seed = string.Concat(LookAndSay(_seed));
return _seed.Length;
}
public static IEnumerable<int> LookAndSay(string data)
{
var currentDigit = data[0];
int count = 1, place = 1;
while (place < data.Length)
{
if (data[place] == currentDigit) count++;
else
{
yield return count;
yield return currentDigit - '0';
currentDigit = data[place];
count = 1;
}
place++;
}
yield return count;
yield return currentDigit - '0';
}
}

View File

@ -0,0 +1 @@
111221