daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Feb 19th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.    }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top