Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple lifehack solution in Clear category for Four To The Floor by kdim
def is_covered(room, sensors):
k = 4 if max(room) <= 300 else 1
for x in range(0, room[0]*k + 1):
for y in range(0, room[1]*k + 1):
if all(map(lambda s: (x - s[0]*k) ** 2 + (y - s[1]*k) ** 2 > (s[2]*k) ** 2, sensors)):
return False
return True
if __name__ == '__main__':
print("Example:")
print(is_covered([200, 150], [[100, 75, 130]]))
assert is_covered([300,150],[[40,60,240],[240,140,100],[295,10,50]]) == False
assert is_covered([200, 150], [[100, 75, 130]]) == True
assert is_covered([200, 150], [[50, 75, 100], [150, 75, 100]]) == True
assert is_covered([200, 150], [[50, 75, 100], [150, 25, 50], [150, 125, 50]]) == False
assert is_covered([200, 150], [[100, 75, 100], [0, 40, 60], [0, 110, 60], [200, 40, 60], [200, 110, 60]]) == True
assert is_covered([200, 150], [[100, 75, 100], [0, 40, 50], [0, 110, 50], [200, 40, 50], [200, 110, 50]]) == False
assert is_covered([200, 150], [[100, 75, 110], [105, 75, 110]]) == False
assert is_covered([200, 150], [[100, 75, 110], [105, 75, 20]]) == False
assert is_covered([3, 1], [[1, 0, 2], [2, 1, 2]]) == True
assert is_covered([30, 10], [[0, 10, 10], [10, 0, 10], [20, 10, 10], [30, 0, 10]]) == True
assert is_covered([30, 10], [[0, 10, 8], [10, 0, 7], [20, 10, 9], [30, 0, 10]]) == False
print("Coding complete? Click 'Check' to earn cool rewards!")
Feb. 1, 2021