diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-08 11:06:56 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-08 11:06:56 +0100 |
| commit | 29e33f8f6a31565f5a2671b1c459ff1b829630f7 (patch) | |
| tree | c051274a9e9a895049a077a6bdce9056dfb9afb1 /solutions/py/03-2.py | |
| parent | d16fc72a33fced8c8623bea6cf9cdd9cf8999024 (diff) | |
| download | aoc-29e33f8f6a31565f5a2671b1c459ff1b829630f7.tar.gz | |
Refactor and create main.py
Diffstat (limited to 'solutions/py/03-2.py')
| -rw-r--r-- | solutions/py/03-2.py | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/solutions/py/03-2.py b/solutions/py/03-2.py deleted file mode 100644 index 0bb1efc..0000000 --- a/solutions/py/03-2.py +++ /dev/null @@ -1,41 +0,0 @@ -import math - -def intersection(l1, l2): - return [value for value in l2 if value in l1] - -def man_dist(point): - return abs(point[0]) + abs(point[1]) - -wire1 = {} -wire2 = {} -# wire {(x,y) : dist} -for wire in (wire1, wire2): - x = 0 - y = 0 - dx = 0 - dy = 0 - steps = 0 - for move in input().split(","): - if move[0] == "D": - dx = 0 - dy = -1 - elif move[0] == "U": - dx = 0 - dy = 1 - elif move[0] == "R": - dx = 1 - dy = 0 - elif move[0] == "L": - dx = -1 - dy = 0 - for i in range(int(move[1:])): - x += dx - y += dy - steps += 1 - wire[(x, y)] = steps - -points = intersection(list(wire1.keys()), list(wire2.keys())) -length = wire1[points[0]] + wire2[points[0]] -for point in points[1:]: - length = min(length, wire1[point] + wire2[point]) -print(length) |
