#!/usr/bin/env python visited_houses_human = [] current_house_human = (0, 0) visited_houses_robot = [] current_house_robot = (0, 0) count = 0 with open("inputd3.txt", "r") as f: for input in f: for x in input: if x == "^" and count % 2 == 0: current_house_human = (current_house_human[0] - 1, current_house_human[1]) elif x == "^" and count % 2 == 1: current_house_robot = (current_house_robot[0] - 1, current_house_robot[1]) elif x == "v" and count % 2 == 0: current_house_human = (current_house_human[0] + 1, current_house_human[1]) elif x == "v" and count % 2 == 1: current_house_robot = (current_house_robot[0] + 1, current_house_robot[1]) elif x == ">" and count % 2 == 0: current_house_human = (current_house_human[0], current_house_human[1] + 1) elif x == ">" and count % 2 == 1: current_house_robot = (current_house_robot[0], current_house_robot[1] + 1) elif x == "<" and count % 2 == 0: current_house_human = (current_house_human[0], current_house_human[1] - 1) else: current_house_robot = (current_house_robot[0], current_house_robot[1] - 1) if count % 2 == 0: visited_houses_human.append(current_house_human) else: visited_houses_robot.append(current_house_robot) count += 1 print(len(set(visited_houses_human + visited_houses_robot)))