Fill all the numbers from 1 to 8 in the diagram shown below ...
Software QA/Tests Interview Questions from Microsoft
(Continued from previous question...)
Fill all the numbers from 1 to 8 in the diagram shown below ...
Question:
fill all the numbers from 1 to 8 in the diagram shown below such that no two consecutive numbers are next to each other(either horizontally vertically or diagonally) i hope i am clear .. i mean 1 can not have a neighbor as 2 , 5 can't have neighbor as 6 or 4 ...

 

   

   

 

maybe an answer1:
More outputs and many more
Y7Y Y2Y Y2Y Y3Y
413 685 314 547
685 413 586 261
Y2Y Y7Y Y7Y Y8Y
The logic behind this is,
Start filling any number in first row. say Y5Y. and proceed further with the given rule
maybe an answer2:
b[k] ={1,2,3,4,5,6,7,8}
m = 3
n = 3
V()
for each i from 0 to n1
for each j from 0 to m1
if((a[i][j] != a[i+1][j] +/ 1) && (a[i][j] != a[i][j+1] +/ 1) && (a[i][j] != a[i1][j] +/ 1) && (a[i][j] != a[i][j1] +/ 1))
return true
else
return false
SS(k)
if(k == 7)
if(V())
for each i from 0 to n1
for each j from o to m1
print a[i][j]
for each i from 0 to n1
for each i from 0 to m1
if(!((i == 0 && j ==0 )  (i == 0 && j ==2)  (i == 2 && j ==0)  (i == 2 && j ==2)))
a[i][j] = b[k]
SS(k+1)
maybe an answer3:
b[k] ={1,2,3,4,5,6,7,8}
m = 3
n = 3
V()
for each i from 0 to n1
for each j from 0 to m1
if((a[i][j] != a[i+1][j] +/ 1) && (a[i][j] != a[i][j+1] +/ 1) && (a[i][j] != a[i1][j] +/ 1) && (a[i][j] != a[i][j1] +/ 1))
return true
else
return false
SS(k)
if(k == 7)
if(V())
for each i from 0 to n1
for each j from o to m1
print a[i][j]
return
for each i from 0 to n1
for each i from 0 to m1
if(!((i == 0 && j ==0 )  (i == 0 && j ==2)  (i == 2 && j ==0)  (i == 2 && j ==2)))
a[i][j] = b[k]
SS(k+1)
(Continued on next question...)
Other Interview Questions
