/** * Solutions for the assignments of week 6. * @author Camil Staps, s4498062 */ public class Main { /** * Create a new sliding game, attempt to solve it and if it succeeds show a solution. * @param args command-line arguments are ignored. */ public static void main(String[] args) { // Some examples: // N = 5 //int[] x = {7,17,9,4,5,1,12,15,6,10,3,23,25,14,8,22,2,18,19,24,16,21,11,13,20}; // May take some time (that is, it did not find a solution after some hours here, I didn't check if there is one) //int[] x = {2,4,6,8,10,1,3,5,7,9,12,14,16,18,20,11,13,15,17,19,21,22,23,24,25}; // Solution in 90 // N = 4 //int[] x = {2,3,10,11,14,1,13,15,5,4,8,7,6,12,9,16}; // Solution in 112 //int[] x = {10,8,16,7,6,13,15,3,14,1,4,2,5,9,12,11}; // Solution in 144 //int[] x = {9,12,5,4,2,16,7,11,3,6,10,13,14,1,8,15}; // Solution in 140 // N = 3 //int[] x = {8,7,6,5,4,3,1,2,9}; // No solution (evaluates 292102 different boards before failing) int[] x = {5,9,3,4,6,2,8,7,1}; // Solution in 35 SlidingGame sg = new SlidingGame(x); System.out.println("Solving:\n" + sg); Solver s = new Solver(sg); if (s.solve()) { System.out.println("Success!"); System.out.println(s.getWinner()); } else { System.out.println("Failure..."); } } }