brute-force to predict probe results solution in Clear category for Ore In The Desert by Leonix
Figure out all possible cells that may contain ore,
taking into account previous probe results.
From among those candidates pick the one that better splits the rest of candidates
into groups by distance to probe location in question.
from collections import Counter
if len(previous) == 0:
return [0, 2]
candidates = [(x, y) for x in range(10) for y in range(10)
if all(result == dist(x, y, x1, y1) for x1, y1, result in previous)]
return min(candidates, key=lambda a:max(Counter(dist(x, y, a, a) for x, y in candidates).values()))
def dist(x1, y1, x2, y2):
return round(((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5)
July 15, 2020