ben
/
aoc
1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
Ben Harris 31fe78fbc3 add missing test input for 2022 day 16
continuous-integration/drone/push Build is passing Details
2023-12-03 01:55:27 -05:00
Ben Harris ace7201859 prefer char.IsAsciiDigit over char.IsDigit 2023-12-03 01:53:48 -05:00
4 changed files with 17 additions and 5 deletions

View File

@ -57,6 +57,7 @@ public class Test2022
[DataRow(typeof(Day13), "13", "140")]
[DataRow(typeof(Day14), "24", "93")]
[DataRow(typeof(Day15), "26", "56000011")]
// [DataRow(typeof(Day16), "1651", "")]
public void CheckTestInputs(Type dayType, string part1, string part2) =>
Common.CheckDay(dayType, part1, part2, true);
}

View File

@ -16,11 +16,12 @@ public sealed class Day18() : Day(2020, 18, "Operation Order")
var postfixStack = new Stack<char>();
foreach (var c in expr)
if (char.IsDigit(c))
if (char.IsAsciiDigit(c))
{
postfixNotation.Append(c);
}
else switch (c)
else
switch (c)
{
case '(':
postfixStack.Push(c);
@ -49,7 +50,7 @@ public sealed class Day18() : Day(2020, 18, "Operation Order")
var expressionStack = new Stack<long>();
foreach (var c in postfixNotation.ToString())
if (char.IsDigit(c))
if (char.IsAsciiDigit(c))
{
expressionStack.Push((long)char.GetNumericValue(c));
}

View File

@ -0,0 +1,10 @@
Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valves CC, AA
Valve CC has flow rate=2; tunnels lead to valves DD, BB
Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE
Valve EE has flow rate=3; tunnels lead to valves FF, DD
Valve FF has flow rate=0; tunnels lead to valves EE, GG
Valve GG has flow rate=0; tunnels lead to valves FF, HH
Valve HH has flow rate=22; tunnel leads to valve GG
Valve II has flow rate=0; tunnels lead to valves AA, JJ
Valve JJ has flow rate=21; tunnel leads to valve II

View File

@ -10,7 +10,7 @@ public class Day01() : Day(2023, 1, "Trebuchet?!")
}
public override object Part1() =>
Input.Sum(line => (line.First(char.IsDigit) - '0') * 10 + (line.Last(char.IsDigit) - '0'));
Input.Sum(line => (line.First(char.IsAsciiDigit) - '0') * 10 + (line.Last(char.IsAsciiDigit) - '0'));
public override object Part2() =>
Input.Sum(line =>
@ -19,7 +19,7 @@ public class Day01() : Day(2023, 1, "Trebuchet?!")
for (var i = 0; i < line.Length; i++)
{
if (char.IsDigit(line[i]))
if (char.IsAsciiDigit(line[i]))
{
digits.Add(item: line[i] - '0');
continue;