Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Ore In The Desert solution in Uncategorized category for Ore In The Desert by capback250
from random import choice
def checkio(args):
variants = {0:[9, 0], 1:[0, 9], 2:[9, 9]}
return variants[len(args)] if len(args) in variants else choice(find_insersect(args))
def find_insersect(circles):
intersections = []
x = 0
while x < 10:
y = 0
while y < 10:
counter = 0
for c in circles:
Xc, Yc, r = c[0], c[1], c[2]
if valid(x, y, Xc, Yc, r + 0.49) and not valid(x, y, Xc, Yc, r - 0.5):
counter += 1
if counter == 3:
intersections.append([x, y])
y += 1
x += 1
return intersections
def valid(x, y, Xc, Yc, r):
return ((Xc-x)**2 + (Yc-y)**2)**0.5 <= r
Jan. 15, 2016