import
java.util.*;
class
eightPuzzle{
static HashMap<Integer,int[][]>
map = new HashMap<>(); static int[][] Store = new int[362880][9]; static
String[] st = new String[500];
static ArrayList<String> stList = new
ArrayList<>();
public static void main(String a[]){
int[][] start = {
{1, 2, 3},
{4, 5, 6},
{0, 7, 8}};
stList.add("123456078");
int [][] last = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 0}};
map.put(1,start);
int x=0,y=0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
System.out.print(start[i][j]+ " ");
if(start[i][j]==0)
{
x=i;y=j;
}
}
System.out.println();
}
System.out.println("i :"+x+" j:"+y);
}
static String swap(String str, int i, int j)
{
StringBuilder sb = new StringBuilder(str);
sb.setCharAt(i, str.charAt(j));
sb.setCharAt(j, str.charAt(i));
return sb.toString();
}
void move(int p, String input)
{
if(p==0 || p==3)
{
input = swap(input,0,3);
stList.add(input);
if(p==3)
{
input = swap(input,3,6);
stList.add(input);
}
}
}
}
No comments:
Post a Comment