text: from functools import reduce
  
  
  """
  --- Day 3: Perfectly Spherical Houses in a Vacuum ---
  
  Santa is delivering presents to an infinite two-dimensional grid of houses.
  
  He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via
  radio and tells him where to move next. Moves are always exactly one house to the north (^), south (v), east (>), or
  west (<). After each move, he delivers another present to the house at his new location.
  
  However, the elf back at the north pole has had a little too much eggnog, and so his directions are a little off, and
  Santa ends up visiting some houses more than once. How many houses receive at least one present?
  
  For example:
  
  > delivers presents to 2 houses: one at the starting location, and one to the east.
  ^>v< delivers presents to 4 houses in a square, including twice to the house at his starting/ending location.
  ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses.
  Your puzzle answer was 2592.
  
  --- Part Two ---
  
  The next year, to speed up the process, Santa creates a robot version of himself, Robo-Santa, to deliver presents with
  him.
  
  Santa and Robo-Santa start at the same location (delivering two presents to the same starting house), then take turns
  moving based on instructions from the elf, who is eggnoggedly reading from the same script as the previous year.
  
  This year, how many houses receive at least one present?
  
  For example:
  
  ^v delivers presents to 3 houses, because Santa goes north, and then Robo-Santa goes south.
  ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up back where they started.
  ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one direction and Robo-Santa going the other.
  Your puzzle answer was 2360.
  
  """
  
  
  class Coordinate:
  
      def __init__(self, x, y):
          self.x = x
          self.y = y
  
      def navigate(self, direction):
          directions = {
              "<": self.__navigate_west,
              ">": self.__navigate_east,
              "v": self.__navigate_south,
              "^": self.__navigate_north
          }
          return directions[direction]()
  
      def __navigate_west(self):
          return Coordinate(self.x - 1, self.y)
  
      def __navigate_east(self):
          return Coordinate(self.x + 1, self.y)
  
      def __navigate_south(self):
          return Coordinate(self.x, self.y - 1)
  
      def __navigate_north(self):
          return Coordinate(self.x, self.y + 1)
  
      def __hash__(self):
          return hash((self.x, self.y))
  
      def __eq__(self, other):
          return other != None and self.x == other.x and self.y == other.y
  
  
  def find_number_of_houses(input):
      coordinates = [Coordinate(0, 0)]
      for direction in input:
          new_coordinate = coordinates[-1].navigate(direction)
          coordinates.append(new_coordinate)
  
      return len(set(coordinates))
  
  
  def find_number_of_houses_with_robots(input, number_of_santas):
      coordinates = dict(map(
          lambda santa_index: (santa_index, [Coordinate(0, 0)]),
          range(number_of_santas)))
      for direction, santa_index in zip(input, list(range(number_of_santas)) * len(input)):
          new_coordinate = coordinates[santa_index][-1].navigate(direction)
          coordinates[santa_index].append(new_coordinate)
  
      return len(set(reduce(
          lambda result, collection: result + collection,
          coordinates.values(),
          [])))
  
  
  if __name__ == "__main__":
      input = ">^^v^<>v<<<v<v^>>v^^^<v<>^^><^<<^vv>>>^<<^>><vv<<v^<^^><>>><>v<><>^^<^^^<><>>vv>vv>v<<^>v<>^>v<v^<>v>><>^v<<<<v^vv^><v>v^>>>vv>v^^^<^^<>>v<^^v<>^<vv^^<^><<>^>><^<>>><><vv><>v<<<><><>v><<>^^^^v>>^>^<v<<vv^^<v<^<^>^^v^^^^^v<><^v><<><^v^>v<<>^<>^^v^<>v<v^>v>^^<vv^v><^<>^v<><^><v^><><><<<<>^vv^>^vvvvv><><^<vv^v^v>v<<^<^^v^<>^<vv><v<v^v<<v<<^^>>^^^v^>v<><^vv<<^<>v<v><><v^^><v<>^^>^^>v^>^<<<<v><v<<>v><^v>^>><v^^<^>v<vvvv<>>>>>^v^^>v<v<^<vv>^>^vv^>vv^^v<<^<^^<>v>vv^v>><>>>v^>^>^^v<>^<v<<>^vv>v^<<v>v<<><v>^vvv<v<vvv^v<vv<v^^^>v><<^<>><v^^>^v^>>^v<^<><v<>>v^<>>v<>>v^^^><^>>vvvv>^v<^><<>>^<>^>vv><v<<>>^^>v^^^><^<<^^v>v<^<<>v>^^vvv^v^>v^<>^^<>v^v>v>v<v^>vv>^^v<>v>>^<>><>v>v^<<vvvv<vvv><v^<^>^v<>>^><v>><>^<v>v<v>vv^>>vvv<>v>v<v^>>^>>v<<>^<>^<>>>^v<<<^<^v>vv^>><<><v^>^v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>^<<<<v<^<<^^>>^<><^>><<>^>v>^^^v>>^<^^v><v^v>^><<><>>^>>^<<v<>^v<>^>^<v>>vv>^vvv<<v<<^>^>^<<^^<>^^^^vvv<>^vv<vvvvv^^>^^<^>>><>v^<><^<<^>v^^v<>>^vv<>v^^<>>v^vvvvv<<v^<v^^>>><vvvvv>><^>vv>v^v^<v<^>^^><^>^^^^v<><^v<<>v^>v>>vv<<>^<v^^>vvv>^^<v^<>vv^><>><v^^v<>^>>^>v><>>^^v>^>^>>>^>v<^v>v>^<^^^^^>>v<v<>>v<<^>^<v<<>^^>><<^><>v<>^^^vv<>^^>><<^^>v>vv>vv>v^>^v>v^^<>>><<v><v<<>>v><>vvv^^v>^^>^vvvv^>^<>^vvvv><v><v<>>><>^<^vv<>^v<^v<>^vvv<<>><vvv^>>^><<vv^<v^>^<v<<^^>^^<^^v^>v<>v^v><>><v^^>>^vvv><^vv>v^<^<^v>>v^^>^vvv^<v^^v^^>v<^<>>^<>>>^^<><^^vv<>^vv^<>>>>^^<<^^<>vv^^><>^^<v<<v>^<v^^>^v<><><>vvv>^v^>>vv<<^v<<>><v>^><^>>>^<^<^^>vv^<<^<>>^^><><<v>^^<v>>v<<vvvv>^v^vv>><^^<<^>>v>v<^^^<^><^^vv>^vv<^<vv<>v><^<><v><^^^>>^<><^<v>>>>v^<v>>>>>v<><^^>v<^<^>><v<>^>vv>^^v^v^<<v<><<<^v^><<^<><<<<v<^>><<<>v>>vv><vv<><<^<^<><vv>^^^^<>v<<<<v>vv<>vv^^^>><>vv^><>>^vv<<><^^vv<>v^>>^<<>^<v^<^>v<"
      print("visited houses alone:", find_number_of_houses(input))
      print("visited houses with robot:",
            find_number_of_houses_with_robots(input, 2))
  