Thanks all for replying,

Tim Moores wrote:

If I were to solve this, I might resort to Prolog instead.

Prolog is very nice subject which I never used. Surely it will help to solve this problem.

But for me I first prefer basic java, then advance java. Same time I will study this new subject.

Piet Souris wrote:

1) do you use all the 8 numbers 1...8, or is it allowed to have say 3 8's in the matrix?

I am using 1 to 8 for each box. (1,2,3,4,5,6,7,8)

I dont know what is ' 3 8's in the matrix'.

Piet Souris wrote:

2) if a = 2; then I assume that the neighboring cells (b, c, d, e) may not conrtain either 1 or 3

Yes, same way apply for each cell/box.

Piet Souris wrote:

3) how did you get a total number of possibilities of 1.6M?

&

Campbell Ritchie wrote:

. . . . (I calculate total possibilities are 16777216.) . . ..

16777216 = 2²⁴, which suggests to me that the eight boxes don't have to contain distinct numbers, otherwise you would be calculating factorials.

Might I calculate with wrong formula.

I am trying to find out how many possibilities of putting 8 numbers in 8 boxes. So I use 8^8 = 16777216.

But Now I am searching right formula for find total possibilities.

Then i will apply another formula for find accurate possibilities from those total possibilities.

Need to refresh Maths knowledge also.

I found 1 link related to find possibilities might that formula right for this problem.

Permutation Formula
Piet Souris wrote:

4) we have a dedicated forum for all things puzzles and programming 'programming diversions'. Have a look, I think you will like it.

I never seen this section so I put this question in 'Beginning Java'. I decided to solve this problem with only basic java programming.

integer, arithmetic operations(addition, subtraction, division, multiplication), for, while, if-else etc only.

If I succeed then I move more optimize way. So understand importance of optimization.

As I thought. Might this way is not right way.

Need guidance from Java & Mathematics people.

Campbell Ritchie wrote:

Mandar Khire wrote:. . . 2. If 'd' have 1 then its neighboring box are 'a','b','c','e','g','h'. So those four box should not have number 2. etc etc

Foiur? Six, surely?

Yes.

For simplicity as following:-