This commit is contained in:
2022-12-15 16:05:38 +02:00
parent 1d06422f87
commit e63c471b96

23
15/o.py
View File

@@ -1,7 +1,7 @@
import os
input = open(os.path.dirname(__file__) +
"/input-demo.txt", "r").readlines()
"/input.txt", "r").readlines()
beacons = []
sensors = []
@@ -28,25 +28,16 @@ def getcoverage(b, Y):
for X in range(x-d0, x+d0):
if (abs(x-X)+abs(y-Y)) <= d0:
coverage.add((X, Y))
# for Y in range(y-d0, y+d0):
#print(X, Y, abs(x-X)+abs(y-Y))
return coverage
#testy = 2000000
testy = 10
testy = 2000000
fullcoverage = set()
for i in range(len(sensors)):
cov = getcoverage(i, testy)
# print(cov)
fullcoverage.update(cov)
# print(fullcoverage)
testset = set()
for s in fullcoverage:
if s[1] == testy:
@@ -54,14 +45,4 @@ for s in fullcoverage:
nonbeacons = testset.difference(set(beacons))
# print(sorted(set(beacons)))
# print(sorted(testset))
for b in beacons:
if b[1] == testy:
print(b[0]*4000000+b[1])
print(len(testset))
print(len(nonbeacons))