-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay06Part2.cs
35 lines (30 loc) · 968 Bytes
/
Day06Part2.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
using AdventOfCode.Util;
using Microsoft.Extensions.Logging;
namespace AdventOfCode.Solutions.Day06;
[Solution("Day06", "Part2")]
public class Day06Part2 : Day06
{
private readonly ILogger _logger;
public Day06Part2(ILogger<Day06Part2> logger) => _logger = logger;
public override void Run(string inputFile)
{
var race = ParseRace(inputFile);
var result = race.CountWaysToWin();
_logger.LogInformation("There are [{result}] ways to win.", result);
}
private static BoatRace<long> ParseRace(string inputFile)
{
var lines = inputFile.SplitByEOL();
var time = long.Parse(
string.Join("",
Expressions.Numbers().Matches(lines[0])
)
);
var distance = long.Parse(
string.Join("",
Expressions.Numbers().Matches(lines[1])
)
);
return new BoatRace<long>(time, distance);
}
}