ben
/
aoc
1
0
Fork 0

2015 day 8

This commit is contained in:
Ben Harris 2022-11-13 14:12:09 -05:00
parent cb503f40fe
commit faf1fb1d77
3 changed files with 17 additions and 5 deletions

View File

@ -13,6 +13,7 @@ public class Test2015
[DataRow(typeof(Day05), "258", "53")]
// [DataRow(typeof(Day06), "543903", "14687245")]
[DataRow(typeof(Day07), "3176", "14710")]
[DataRow(typeof(Day08), "1342", "2074")]
public void TestAllDays(Type dayType, string part1, string part2)
{
Common.CheckDay(dayType, part1, part2);
@ -25,7 +26,8 @@ public class Test2015
// [DataRow(typeof(Day04), "609043", "6742839")]
[DataRow(typeof(Day05), "1", "1")]
[DataRow(typeof(Day06), "1000000", "1000000")]
// [DataRow(typeof(Day07), "", "")] // test input doesn't have "a" key
// [DataRow(typeof(Day07), "", "")] // test input doesn't have "a" wire
[DataRow(typeof(Day08), "12", "19")]
public void CheckTestInputs(Type dayType, string part1, string part2)
{
Day.UseTestInput = true;

View File

@ -3,13 +3,19 @@
/// <summary>
/// Day 8: <see href="https://adventofcode.com/2015/day/8"/>
/// </summary>
public sealed class Day08 : Day
public sealed partial class Day08 : Day
{
public Day08() : base(2015, 8, "Puzzle Name")
[GeneratedRegex(@"^""(\\x..|\\.|.)*""$")]
private static partial Regex CharSet();
public Day08() : base(2015, 8, "Matchsticks")
{
}
public override object Part1() => "";
int CharCount(string arg) => CharSet().Match(arg).Groups[1].Captures.Count;
int EncodedCount(string arg) => 2 + arg.Sum(c => c is '\\' or '\"' ? 2 : 1);
public override object Part2() => "";
public override object Part1() => Input.Sum(line => line.Length) - Input.Sum(CharCount);
public override object Part2() => Input.Sum(EncodedCount) - Input.Sum(line => line.Length);
}

View File

@ -0,0 +1,4 @@
""
"abc"
"aaa\"aaa"
"\x27"