diff options
Diffstat (limited to 'Day6.cs')
-rw-r--r-- | Day6.cs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Day6.cs b/Day6.cs index 50dd605..d92b402 100644 --- a/Day6.cs +++ b/Day6.cs @@ -5,14 +5,15 @@ namespace aoc2019 { internal sealed class Day6 : Day { - public override int DayNumber => 6; - private readonly Dictionary<string, string> input; + public Day6() { input = Input.ToDictionary(i => i.Split(')')[1], i => i.Split(')')[0]); } + public override int DayNumber => 6; + private List<string> GetParents(string obj) { var res = new List<string>(); @@ -29,11 +30,11 @@ namespace aoc2019 public override string Part2() { - List<string> you = GetParents("YOU"); - List<string> san = GetParents("SAN"); - int common = 1; - for (; you[^common] == san[^common]; common++); + var you = GetParents("YOU"); + var san = GetParents("SAN"); + var common = 1; + for (; you[^common] == san[^common]; common++) ; return $"{you.Count + san.Count - common * 2}"; } } -} +} \ No newline at end of file |