#!/usr/bin/env python my_raw_input = "" with open("/home/login/bin/advent/input11.txt") as f: my_raw_input = f.read() my_input = my_raw_input.split(',') # my_input is a list created from the set {"n","s","ne","nw","se","sw"} state = {'x':0,'y':0} steps_furthest_away = 0 for step in my_input: if step == 'n': state['y'] += 1 elif step == 's': state['y'] -= 1 elif step == 'se': state['x'] += 1 elif step == 'nw': state['x'] -= 1 elif step == 'ne': state['x'] += 1 state['y'] += 1 elif step == 'sw': state['x'] -= 1 state['y'] -= 1 if abs(state['x']) + abs(state['y']) > steps_furthest_away: steps_furthest_away = abs(state['x']) + abs(state['y']) manhattan_distance = abs(state['x']) + abs(state['y']) print("Part 1: " + str(manhattan_distance)) print("Part 2: " + str(steps_furthest_away))