private static string SolveSilver(string input) { var walker = new CityWalker(input); var location = walker.GetLocations().Last(); var distance = Math.Abs(location.X) + Math.Abs(location.Y); return($"We think Easter Bunny HQ is at {location.X},{location.Y} for a total distance of {distance}"); }
private static string SolveGold(string input) { var walker = new CityWalker(input); var history = new HashSet <Coordinate>(); Coordinate found = null; foreach (var location in walker.GetLocations()) { if (history.Contains(location)) { found = location; break; } history.Add(location); } var distance = found != null?Math.Abs(found.X) + Math.Abs(found.Y) : 0; return($"Easter Bunny HQ is actually at {found?.X},{found?.Y} for a total distance of {distance}"); }