# 5x5 table with unique properties

1 3 2 3 1
3 3 2 3 3
2 2 3 3 2
3 3 3 4 4
1 3 2 4 1

This 5x5 table has unique properties.
Each number (x) in a cell means:

The cell is surrounded (including diagonal neighbours) by x unique numbers in the squares surrounding it.

Example:
(2,2) cell (red) is 3, so it is surrounded by 3 unique numbers (1,2 and 3)
(4,4) cell (blue) is 4, so it is surrounded by 4 unique numbers (1,2, 3 and 4)

The Question

3
2
2
3

Fill in the blanks so the table has the same unique properties.

One solution, with

entries at most 4. It was found by basic depth-first search with pruning (checking if the neighbouring condition hold at each cell). This is colloquially called as backtracking.

Here it comes:

 3 2 3 3 3
3 4 4 4 2
3 4 1 4 3
2 4 4 4 3
3 3 3 2 3

Other solutions might be possible. Edit: this is the unique solution.

• Edit: this is the unique solution. Why? – CodeNewbie Sep 22 '16 at 12:47
• @CodeNewbie see edit summary. It is clear that the value in each of the cells is bounded, so this is a finite problem and the only thing you need to do is to check all cases. – Matsmath Sep 22 '16 at 12:48