diff options
| -rw-r--r-- | solutions/py/01-1.py | 4 | ||||
| -rw-r--r-- | solutions/py/02-2.py | 4 | ||||
| -rw-r--r-- | solutions/py/03-1.py | 6 | ||||
| -rw-r--r-- | solutions/py/03-2.py | 7 |
4 files changed, 4 insertions, 17 deletions
diff --git a/solutions/py/01-1.py b/solutions/py/01-1.py index fa43b34..598caf4 100644 --- a/solutions/py/01-1.py +++ b/solutions/py/01-1.py @@ -8,6 +8,4 @@ for line in sys.stdin: break fuel = math.floor(mass / 3) - 2 s += fuel - print("adding", fuel) - print("at", s) -print("sum", s) +print(s) diff --git a/solutions/py/02-2.py b/solutions/py/02-2.py index 9a71a7f..2949629 100644 --- a/solutions/py/02-2.py +++ b/solutions/py/02-2.py @@ -1,8 +1,6 @@ import sys -program = input().split(",") -for i in range(len(program)): - program[i] = int(program[i]) +program = [int(x) for x in input().split(",")] for n in range(100): for v in range(100): diff --git a/solutions/py/03-1.py b/solutions/py/03-1.py index dea1c05..3f26a84 100644 --- a/solutions/py/03-1.py +++ b/solutions/py/03-1.py @@ -1,14 +1,11 @@ import math - def intersection(l1, l2): - tmp = set(l1) - return [value for value in l2 if value in tmp] + return [value for value in l2 if value in l1] def man_dist(point): return abs(point[0]) + abs(point[1]) - wire1 = [] wire2 = [] for wire in (wire1, wire2): @@ -34,7 +31,6 @@ for wire in (wire1, wire2): y += dy wire.append((x, y)) points = intersection(wire1, wire2) -print(len(points)) dist = man_dist(points[0]) for point in points[1:]: dist = min(dist, man_dist(point)) diff --git a/solutions/py/03-2.py b/solutions/py/03-2.py index adb95a2..0bb1efc 100644 --- a/solutions/py/03-2.py +++ b/solutions/py/03-2.py @@ -1,13 +1,11 @@ import math def intersection(l1, l2): - tmp = set(l1) - return [value for value in l2 if value in tmp] + 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} @@ -37,9 +35,6 @@ for wire in (wire1, wire2): wire[(x, y)] = steps points = intersection(list(wire1.keys()), list(wire2.keys())) -print(len(points)) -for point in points: - print(point, wire1[point], wire2[point]) length = wire1[points[0]] + wire2[points[0]] for point in points[1:]: length = min(length, wire1[point] + wire2[point]) |
