diff options
Diffstat (limited to 'Day10.cs')
-rw-r--r-- | Day10.cs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Day10.cs b/Day10.cs index eec1e57..5886556 100644 --- a/Day10.cs +++ b/Day10.cs @@ -1,14 +1,12 @@ -using aoc2019.lib; using System; using System.Collections.Generic; using System.Linq; +using aoc2019.lib; namespace aoc2019 { internal sealed class Day10 : Day { - public override int DayNumber => 10; - private readonly HashSet<(int x, int y)> asteroids = new HashSet<(int x, int y)>(); private (int x, int y) best = (x: -1, y: -1); private int bestcansee; @@ -23,12 +21,14 @@ namespace aoc2019 .ToHashSet(); } + public override int DayNumber => 10; + public override string Part1() { foreach (var asteroid in asteroids) { var cansee = asteroids - .Except(new[] { asteroid }) + .Except(new[] {asteroid}) .Select(a => (x: a.x - asteroid.x, y: a.y - asteroid.y)) .GroupBy(a => Math.Atan2(a.y, a.x)) .Count(); @@ -39,12 +39,14 @@ namespace aoc2019 bestcansee = cansee; } } + return $"{bestcansee}"; } public override string Part2() { - static IEnumerable<(int x, int y, double angle, double dist)> GetValue(Queue<(int x, int y, double angle, double dist)> q) + static IEnumerable<(int x, int y, double angle, double dist)> GetValue( + Queue<(int x, int y, double angle, double dist)> q) { if (q.Count > 0) yield return q.Dequeue(); } @@ -70,4 +72,4 @@ namespace aoc2019 .ToString(); } } -} +} \ No newline at end of file |