From 5b4353d91fd80a2f060ce15ebe95e8d316373671 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 5 Dec 2019 01:19:39 -0500 Subject: tidy up, refactor program.cs by day --- Day3.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Day3.cs') diff --git a/Day3.cs b/Day3.cs index e9cbdca..e3f998f 100644 --- a/Day3.cs +++ b/Day3.cs @@ -7,24 +7,26 @@ namespace aoc2019 { internal class Day3 : Day { + public override int DayNumber => 3; + private readonly IEnumerable<(int, int)> intersections; private readonly List> wires; public Day3() { - wires = File.ReadAllLines("input/day3.in").Select(line => ParseWire(line)).ToList(); + wires = File.ReadAllLines("input/day3.in").Select(ParseWire).ToList(); intersections = wires[0].Keys.Intersect(wires[1].Keys); } - public override void Part1() + public override string Part1() { - Console.WriteLine(intersections.Min(x => Math.Abs(x.Item1) + Math.Abs(x.Item2))); + return $"{intersections.Min(x => Math.Abs(x.Item1) + Math.Abs(x.Item2))}"; } - public override void Part2() + public override string Part2() { // add 2 to count (0, 0) on both lines - Console.WriteLine(intersections.Min(x => wires[0][x] + wires[1][x]) + 2); + return $"{intersections.Min(x => wires[0][x] + wires[1][x]) + 2}"; } private static Dictionary<(int, int), int> ParseWire(string line) -- cgit 1.4.1