Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Recursive targeting solution in Clear category for Berserk Rook by DiZ
def berserk_rook(berserker, enemies):
#Target set construction
left = set()
for i,c in enumerate(map(ord, berserker)): ##On the same row/column:
for o in 0,8: ##For each side:
for r in map(chr, range(c-8+o, c+o)): ##Search the
target = ''.join(([r]+list(berserker)+[r])[i::2]) ##closest rook
if target in enemies: ##and
left.add(target) ##target it.
break
#Search through remaining enemies
return len(left)and 1+max(berserk_rook(enemy, enemies-{enemy}) for enemy in left)
Aug. 1, 2014
Comments: