···11+import fileinput
22+33+seen = {}
44+ints = {}
55+66+for wire, line in enumerate(fileinput.input()):
77+ commands = line.split(',')
88+ x = y = 0
99+ steps = 1
1010+1111+ for cmd in commands:
1212+ direction = cmd[0]
1313+ dist = int(cmd[1:])
1414+1515+ for _ in range(dist):
1616+ if direction == 'U':
1717+ y -= 1
1818+ elif direction == 'L':
1919+ x -= 1
2020+ elif direction == 'R':
2121+ x += 1
2222+ else:
2323+ y += 1
2424+2525+ if (x, y) in seen and wire == 1 and (x, y) not in ints:
2626+ ints[(x, y)] = steps + seen[(x, y)]
2727+2828+ if wire == 0 and (x, y) not in seen:
2929+ seen[x, y] = steps
3030+3131+ steps += 1
3232+3333+print "Distance to closest intersection:", min(abs(a) + abs(b) for a, b in ints.keys())
3434+print "Fewest steps to intersection:", min(n for n in ints.values())