Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Berserk Rook by Sim0000
def berserk_rook(berseker, enemies):
pos = []
N = [e for e in enemies if berseker[0] == e[0] and berseker[1] < e[1]]
if N: pos.append(min(N))
S = [e for e in enemies if berseker[0] == e[0] and e[1] < berseker[1]]
if S: pos.append(max(S))
E = [e for e in enemies if berseker[0] < e[0] and berseker[1] == e[1]]
if E: pos.append(min(E))
W = [e for e in enemies if e[0] < berseker[0] and berseker[1] == e[1]]
if W: pos.append(max(W))
return len(pos) and max(berserk_rook(e, enemies - {e}) + 1 for e in pos)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert berserk_rook('d3', {'d6', 'b6', 'c8', 'g4', 'b8', 'g6'}) == 5, "one path"
assert berserk_rook('a2', {'f6', 'f2', 'a6', 'f8', 'h8', 'h6'}) == 6, "several paths"
assert berserk_rook('a2', {'f6', 'f8', 'f2', 'a6', 'h6'}) == 4, "Don't jump through"
July 30, 2014
Comments: