//2565 public static int Solve1(string input) { var santa = new Position(0, 0); var houses = new HashSet<Tuple<int, int>> { new Tuple<int, int>(0, 0) }; foreach (var direction in input) santa.Move(direction).DeliverPresent(houses); return houses.Count; }
public static int Solve2(string input) { var santa = new Position(0, 0); var robot = new Position(0, 0); var houses = new HashSet<Tuple<int, int>> { new Tuple<int, int>(0, 0) }; var moveSanta = true; foreach (var direction in input) { if(moveSanta) santa.Move(direction).DeliverPresent(houses); else robot.Move(direction).DeliverPresent(houses); moveSanta = !moveSanta; } return houses.Count; }
public Position(Position position) { X = position.X; Y = position.Y; }