public int part_one(string input) { var astroids = Astroids.Parse(input); return(astroids .Max(station => Astroids.Relations(station, astroids) .Select(r => r.Angle) .Distinct() .Count())); }
public int part_two(string input) { var astroids = Astroids.Parse(input); var station = astroids .OrderByDescending(s => Astroids.Relations(s, astroids) .Select(r => r.Angle) .Distinct() .Count()) .FirstOrDefault(); var relations = Astroids.Relations(station, astroids) .OrderBy(r => r.Angle) .ThenBy(r => r.Distance) .ToArray(); var vaporized = new HashSet <Point>(); var started = false; var postion = 0; Relation last = default; while (vaporized.Count < 200) { var relation = relations[postion++]; started |= relation.Angle >= Math.PI / 2; if (started && last.Angle != relation.Angle && vaporized.Add(relation.Astroid)) { last = relation; } if (postion >= relations.Length) { postion = 0; } } return(last.Astroid.X * 100 + last.Astroid.Y); }