Guest User

Untitled

a guest
Feb 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. /* determine if puzzle is solvable */
  2. public static boolean isSolvable(int[] state) {
  3. int inversions = 0;
  4. for (int i = 0; i < state.length; i++)
  5. for (int j = i; j < state.length; j++)
  6. if (state[i] < state[j]) inversions++;
  7.  
  8. System.out.println("Inversion: " + inversions);
  9. return true;
  10. }
Add Comment
Please, Sign In to add comment