Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in LISP programming: Implement a SOLVABLE? function to determine if a given stat

ID: 3564723 • Letter: I

Question

in LISP programming:

Implement a SOLVABLE? function to determine if a given state is solvable for a given goal. I.e. not all initial states of the N-puzzle are solvable for a specific goal state. There are two separate sets of states. All states in each set are unreachable from states in the other and vice versa. Test your function on at least 2 unsolvable puzzles. Discuss your solution to detecting and handling unsolvable cases in your report. Explain how you generated the new, novel puzzle instances.

Explanation / Answer

Here is the shortest solution generated by the 8 puzzle program for the initial state given above. (The program animates through each game state)

boolean
Solution::search(PriorityQueue pq)
{ if pq.isEmpty() then
   return false
puz = pq.extract()
if puz.isGoal()
   return true
successors = puz.expand()
   // all possible successors to puz
for each suc in successors do
   pq.insert(suc)
if search(pq)
   return true
else
   return false
}