Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Colder-Warmer - Random solution in Uncategorized category for Colder-Warmer by capback250
def checkio(args):
# print args
ways = [[8, 5], [5, 6], [6, 5], [9, 9], [1, 2], [4, 8], [2, 4], [7, 7], [9, 0], [4, 6]]
can = []
if len(args) < 11:
return ways[len(args) - 1]
for x in [[x, y] for x in range(10) for y in range(10)]:
if analyz(args, x):
can.append(x)
import random
return random.choice(can)
def analyz(args, possible):
summa = 0
for i in range(len(args)-1):
logic = args[i+1][2]
a, b = args[i], args[i+1]
fa = ((possible[0] - a[0])**2 + (possible[1] - a[1])**2) ** .5
fb = ((possible[0] - b[0])**2 + (possible[1] - b[1])**2) ** .5
if logic == -1:
if fa < fb:
summa += 1
if logic == 1:
if fa > fb:
summa += 1
if logic == 0:
if fa == fb:
summa += 1
return summa == len(args) -1
Jan. 25, 2016