Advertisement
steverobinson

Sliding Puzzle solver

Mar 23rd, 2011
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Problem code: SSLIDE
  2. ----------------------
  3.  
  4. Given a initial position of a sliding puzzle determine the moves to arrange them back in order.(A number can be swapped only with x)
  5.  
  6. Initial position
  7.  
  8. 1 2 3
  9. 4 5 x
  10. 6 7 8
  11.  
  12. Final position
  13.  
  14. 1 2 3
  15. 4 5 6
  16. 7 8 x
  17.  
  18. Input
  19.  
  20. Intial position of the puzzle
  21.  
  22. 1 2 3
  23. 4 5 x
  24. 6 7 8
  25.  
  26. is described as 1 2 3 4 5 x 6 7 8
  27.  
  28. Output
  29.  
  30. If it has no solution print unsolvable.
  31. If it has a solution print a string describing the sequence of moves that has to be performed on the puzzle to solve it. (l-left,r-right,u-ip,d-down)
  32.  
  33. Example
  34.  
  35. Input:
  36. 1 2 3 4 5 x 6 7 8
  37.  
  38. Output:
  39. dllurdrulldrr
  40.  
  41. <<Solution development In progress>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement