p1 clean
This commit is contained in:
23
15/o.py
23
15/o.py
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
input = open(os.path.dirname(__file__) +
|
input = open(os.path.dirname(__file__) +
|
||||||
"/input-demo.txt", "r").readlines()
|
"/input.txt", "r").readlines()
|
||||||
|
|
||||||
beacons = []
|
beacons = []
|
||||||
sensors = []
|
sensors = []
|
||||||
@@ -28,25 +28,16 @@ def getcoverage(b, Y):
|
|||||||
for X in range(x-d0, x+d0):
|
for X in range(x-d0, x+d0):
|
||||||
if (abs(x-X)+abs(y-Y)) <= d0:
|
if (abs(x-X)+abs(y-Y)) <= d0:
|
||||||
coverage.add((X, Y))
|
coverage.add((X, Y))
|
||||||
|
|
||||||
# for Y in range(y-d0, y+d0):
|
|
||||||
#print(X, Y, abs(x-X)+abs(y-Y))
|
|
||||||
|
|
||||||
return coverage
|
return coverage
|
||||||
|
|
||||||
|
|
||||||
#testy = 2000000
|
testy = 2000000
|
||||||
testy = 10
|
|
||||||
|
|
||||||
fullcoverage = set()
|
fullcoverage = set()
|
||||||
for i in range(len(sensors)):
|
for i in range(len(sensors)):
|
||||||
cov = getcoverage(i, testy)
|
cov = getcoverage(i, testy)
|
||||||
# print(cov)
|
|
||||||
fullcoverage.update(cov)
|
fullcoverage.update(cov)
|
||||||
|
|
||||||
# print(fullcoverage)
|
|
||||||
|
|
||||||
|
|
||||||
testset = set()
|
testset = set()
|
||||||
for s in fullcoverage:
|
for s in fullcoverage:
|
||||||
if s[1] == testy:
|
if s[1] == testy:
|
||||||
@@ -54,14 +45,4 @@ for s in fullcoverage:
|
|||||||
|
|
||||||
nonbeacons = testset.difference(set(beacons))
|
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))
|
print(len(nonbeacons))
|
||||||
|
|||||||
Reference in New Issue
Block a user