Peg Jumping

Peg Jumping

The mission is in Blocked Mode. Access to the solutions is blocked for a day or two (even after you share your own), until we'll have enough solutions for you to check. All users who've solved the mission will get the notifications about their opening.

The Pin Game is a puzzle that consists of a board with cross-shaped holes, initially filled with pins, except for an empty hole in the center. The goal is to perform valid movements to remove the pins until only one remains. A move is valid if a pin (pivot) can jump horizontally of vertically over an adjacent pin (target) towards an empty hole (target), removing the target pin.

example

You are given a board configuration as a list of 7 strings, each representing a line on the board. Each string contains exactly 7 characters, with '-' (hyphen) in the first two and last two characters of lines 1, 2, 6 and 7, 'o' (lowercase letter) representing a pin, or '.' (dot) representing a hole.

Your program should determine the number of possible valid moves.

Input: List of strings (str).

Output: Integer.

Examples:

assert (
    peg_jump(
        ["--.o.--", "--o.o--", "....o..", "....o..", "o.o.o..", "--o.o--", "--o.o--"]
    )
    == 2
)
assert (
    peg_jump(
        ["--ooo--", "--oo.--", "ooo.ooo", "oo...oo", "ooo.ooo", "--o.o--", "--ooo--"]
    )
    == 11
)
assert (
    peg_jump(
        ["--ooo--", "--oo.--", "oo.o.oo", "o..o..o", "oo.o.oo", "--oo.--", "--ooo--"]
    )
    == 8
)
assert (
    peg_jump(
        ["--ooo--", "--o.o--", "oo.oooo", "o..o..o", "oooo.oo", "--o.o--", "--ooo--"]
    )
    == 10
)