guys can ypu please help me i have this code but i donr know how it works can you please put comment on lines and explsin on comment how it works. Thank you very much please help me because im just beginner in java thanks again.
here's the code:
import java.io.*;
import java.util.*;
class Puzzle
{
public static InputStreamReader a=new InputStreamReader(System.in);
public static BufferedReader b=new BufferedReader(a);
public static void main(String args[]) throws IOException
{
Random myRand=new Random();
int temp=0;
int ctrY = 1;
int ctrX = 0;
int i = 0;
int n[] = new int[16];
int m[][] = new int[6][6];
int x=0,y=0;
boolean win = false;
boolean pass = false;
i = myRand.nextInt()%16;
i = Math.abs(i);
n[0] = i;
while (ctrY <= 15){
i = myRand.nextInt()%16;
i = Math.abs(i);
for (ctrX=0;ctrX<ctrY;ctrX++){
if (n[ctrX]==i){
pass = false;
break;
}else
pass = true;
}//end for
if (pass == true ){
n[ctrX] = i;
ctrY++;
}//endif
}//end while
for(ctrX=0;ctrX<16;ctrX++){
if (n[ctrX]==0){
i = n[15];
n[ctrX] = i;
n[15] = 0;
break;}
}
//initialize m[6][6] to -1
for(ctrY=0; ctrY<=5; ctrY++)
for (ctrX=0; ctrX<=5; ctrX++)
m[ctrY][ctrX]=-1;
i=0;
//transfer values of n[] to m[][]
for(y=1;y<5;y++)
for(x=1;x<5;x++){
m[y][x] = n[i];
i++;
}
temp = 1;
while (win!=true && temp!=0)
{
pass = false;
for(y=1; y<=4; y++){
for (x=1; x<=4; x++)
System.out.print(m[y][x] + "\t");
System.out.println();}