Skip to content
Snippets Groups Projects
is_goal.py 461 B
Newer Older
Michael Mutote's avatar
Michael Mutote committed
MAZE_GOAL = (0, 4)
Michael Mutote's avatar
Michael Mutote committed


Michael Mutote's avatar
Michael Mutote committed
PUZZLE_GOAL = (
    (0, 1, 2),
    (3, 4, 5),
    (6, 7, 8)
)


Michael Mutote's avatar
Michael Mutote committed
def is_goal_maze(state):
    return MAZE_GOAL == state


def is_goal_sudoku(state):
    y, x = 10, 10
    for i, s in enumerate(state):
        if 0 in s:
            (y, x) = (i, s.index(0))
            break
Michael Mutote's avatar
Michael Mutote committed
    return (y, x) == (10, 10)
Michael Mutote's avatar
Michael Mutote committed

Michael Mutote's avatar
Michael Mutote committed

Michael Mutote's avatar
Michael Mutote committed
def is_goal_queens(state):
    return sum(map(sum, state)) == len(state)
Michael Mutote's avatar
Michael Mutote committed


Michael Mutote's avatar
Michael Mutote committed
def is_goal_puzzle(state):
tnbeats's avatar
tnbeats committed
    return PUZZLE_GOAL == state