--- /dev/null
+"""Find the dangerous vents"""
+import numpy as np
+
+vent_field = np.zeros((1000, 1000))
+
+with open("5_input.txt") as f:
+ for line in f:
+ p1, p2 = line.split("->")
+ x1, y1, x2, y2 = [int(x) for x in p1.split(",") + p2.split(",")]
+
+ if x1 == x2:
+ for y in range(min(y1, y2), max(y1, y2) + 1):
+ vent_field[x1][y] += 1
+ elif y1 == y2:
+ for x in range(min(x1, x2), max(x1, x2) + 1):
+ vent_field[x][y1] += 1
+
+print(len(np.argwhere(vent_field > 1)))
--- /dev/null
+"""Find the dangerous vents"""
+import numpy as np
+
+vent_field = np.zeros((1000, 1000))
+
+with open("5_input.txt") as f:
+ for line in f:
+ p1, p2 = line.split("->")
+ x1, y1, x2, y2 = [int(x) for x in p1.split(",") + p2.split(",")]
+
+ if x1 == x2:
+ for y in range(min(y1, y2), max(y1, y2) + 1):
+ vent_field[x1][y] += 1
+ elif y1 == y2:
+ for x in range(min(x1, x2), max(x1, x2) + 1):
+ vent_field[x][y1] += 1
+ else:
+ m = (y2 - y1) // (x2 - x1)
+ c = y1 - (m * x1)
+ for x in range(min(x1, x2), max(x1, x2) + 1):
+ y = (m * x) + c
+ vent_field[x][y] += 1
+
+
+
+print(len(np.argwhere(vent_field > 1)))