public Puzzle swapBlank ( int target ) { int [ ] copy = Arrays . copyOf ( cells , cells . length ) ; int x = copy [ target ] ; copy [ getBlankIndex ( ) ] = x ; copy [ target ] = 8 ; return new Puzzle ( copy ) ; }
Create a copy of the puzzle where the blank swapped with the value in the target position