I have a friend that's in university and he asked me I could help him a bit, so I did that.

He has an assigment where you need to make a puzzel and make output like this:

|--------------------------------|

| 6 | 3 | 3 | 9 |

| 0 | 4 | 10 | 5 |

| 8 | 10 | 1 | 11 |

| 5 | 13 | 2 | 0 |

|--------------------------------|

But the problem is that some number's are the same. and that's not allowed. (2 time's 10, 2 time's 3)

And I don't now how i should fix that.

Here i generate the bord:

package puzzel.slidepuzzle; import java.util.Arrays; import java.util.Random; /* * * Calculation: * List all numbers on the board lexically, i.e., left to right and top to bottom. For each number n in this list, count the number of inversions: the numbers that precede n in the list and that are larger than n. If the total number of inversions, added over all numbers in the list, is even then the puzzle is solvable. If it's odd, the puzzle can't be solved. * int i = Arraylist[huide] -1; * * Formule: * * */ public class ConfigGenerator { private Random randomizer= new Random(); final int rowWidth = 4; final int rowHeight = 4; private int result[][]; public int[][] getRandomConfig(){ int result[][] = new int[rowWidth][rowHeight]; for (int row = 0; row < result.length; row++) { for (int col = 0; col < result[row].length; col++) { result[row][col] = randomizer.nextInt(15); } } for(int i = 0; i < result.length; i++) { for(int j = 0; j < result[i].length; j++) { System.out.print(" | " + result[i][j] + "\t" + " "); //System.out.println(); } System.out.print(" | "); System.out.println(); } return result; } public boolean isSolvable(int[][] config) { return false; } }

In the board class I call this class and run getRandomConfig()

Thanks!