Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Berserk Rook by UFO665
from itertools import permutations
def isJumping(rookV, rookH, lst):
v0, h0 = lst[0]
for v, h in lst[1:]:
if h == h0 and sorted([rookV, v0, v])[1] == v or v == v0 and sorted([rookH, h0, h])[1] == h:
return True
return False
def berserk_rook(berserker, enemies):
result = 0
for p in permutations(enemies, len(enemies)):
v, h = berserker
counter = i = 0
while counter < len(enemies) and (v in p[i] or h in p[i]) and not isJumping(v, h, p[i:]):
v, h = p[i]
counter += 1
i += 1
if counter > result:
result = counter
if result == len(enemies):
break
return result
Jan. 23, 2016
Comments: