Today was a challenging Day 3! I was definitely overthinking this problem, and I also ended up accidentally deleting my Part 1 implementation before moving on to Part 2...it's one of those days 🙃. Here's what I got:

defget_path(wire):i=j=0step=1path={}forvisitinwire:dir,position=visit[0],int(visit[1:])x=y=0ifdir=='U':x=-1elifdir=='D':x=1elifdir=='L':y=-1elifdir=='R':y=1else:raiseException('Unexpected direction')for_inrange(position):i+=xj+=ypath[(i,j)]=stepstep+=1returnpathdefdist(p,q):returnabs(p[0]-q[0])+abs(p[1]-q[1])defcalculate_min_distance(intersections):returnmin(dist(point,(0,0))forpointinintersections)defcalculate_min_steps(intersections,steps_a,steps_b):min_steps=float('inf')forpointinintersections:ifpointnotinsteps_aorpointnotinsteps_b:raiseException('Not an shared path intersection.')min_steps=min(min_steps,steps_a[point]+steps_b[point])returnmin_stepsdata=open('input.txt','r').readlines()wire1,wire2=data[0].strip().split(','),data[1].strip().split(',')path_wire1,path_wire2=get_path(wire1),get_path(wire2)intersections=list(set(path_wire1.keys())&set(path_wire2.keys()))# part 1
print(calculate_min_distance(intersections))# part 2
print(calculate_min_steps(intersections,path_wire1,path_wire2))

## re: Advent of Code 2019 Solution Megathread - Day 3: Crossed Wires VIEW POST

FULL DISCUSSIONToday was a challenging Day 3! I was definitely overthinking this problem, and I also ended up accidentally deleting my Part 1 implementation before moving on to Part 2...it's one of those days 🙃. Here's what I got: