Search
Is the given configuration/state solvable at all? The actual algorithm will be explained at the second lecture. The essential pieces of implementation will be shown live during the computer lab. You can use also the code from npuzzle.py and compare it to your solution of npuzzle.py.
npuzzle.py
The task is to implement a method is_solvable(env), which decides whether a given env (NPuzzle instance) is solvable or not. Implement the function in a module named solvability_check.py and upload it to BRUTE. A correct solution is worth 2 points.
is_solvable(env)
env
solvability_check.py
Example structure of (solvability_check.py):
import npuzzle def is_solvable(env): ''' True or False? ''' # your code comes here if __name__=="__main__": # testing suite env = npuzzle.NPuzzle(3) # instance of NPuzzle class env.reset() # random shuffle env.visualise() # just to show the board # just check print(is_solvable(env)) # should output True or False
When done, upload to the BRUTE
A link to the N-Puzzle solver.