Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple recursion solution in Clear category for Checkers Capture by juestr
def max_checkers_capture(
n: int, position: tuple[int, int], pieces: list[tuple[int, int]]
) -> int:
x, y = position
captures = 0
for px, py in pieces:
dx, dy = px - x, py - y
if abs(dx) == abs(dy) == 1:
new_pos = new_x, new_y = px + dx, py + dy
if 0 <= new_x < n and 0 <= new_y < n and new_pos not in pieces:
new_pieces = pieces.copy()
new_pieces.remove((px, py))
captures = max(captures, 1 + max_checkers_capture(n, new_pos, new_pieces))
return captures
July 16, 2023