little bit of logic

 apk download link: resource sharing summary

Game rules: Put the dots into a certain square, so that the number of dots in each row and column is the same as the given number, and the dots are grouped into groups according to the adjacent ones, and the grouping result should be the same as the given number. the same

Implicit rule: each group is in the shape of 1*n, and one group is completely separated from the other group, that is, the dots of one group are not eight neighbors of the dots of the other group

In the appropriate place below, I explain the 5 methods in turn:

Method 1: Processing of extremely small numbers

Method 2: Processing of very large numbers

Method 3: Each group is mutually exclusive

Method 4: Optional Groups

Method 5: Enumeration of large group positions

(1)

   

Method 1: Processing of extremely small numbers

Each grid has only 2 states in the end, with dots and no dots

When the number of dots whose positions have been determined in a row reaches the number that is calibrated in the row, then no dots are placed in other grids, and the same is true for columns.

Including special cases: if the number is 0, the row (column) is marked directly without dots.

This seems useless. In fact, the key is that those who already know the final state must be marked first, which will have an impact on the subsequent work.

Method 2: Processing of extremely large numbers:

In the same way as the processing of extremely small numbers, when the number of positions where dots may be placed in a row (including the number of places where dots are determined to be placed) is equal to the number marked in this row, these grids must be filled with dots and should be marked immediately. Come out, the same is true for the columns.

Including special cases: if the number is the length and width of the chessboard, then this row (column) will put dots.

(2)

   

(3)

   

(4)

   

(5)

   

(6)

   

(7)

   

(8)

   

(9)

   

(10)

   

(11)

   

(12)

   

(1)

   

(2)

   

(3)

   

(4)

   

(5)

   

(6)

   

(7)

   

(8)

   

(9)

   

(10)

   

(11)

   

(12)

   

(13)

   

(14)

   

(15)

   

(16)

   

(17)

   

(18)

   

(19)

   

(20)

   

(21)

   

(22)

   

(23)

   

(24)

   

(25)

   

(26)

   

(27)

   

(28)

   

(29)

   

(30)

   

(1)

   

(2)

   

(3)

   

(4)

   

(5)

   

Method 3: Each group is mutually exclusive

Because the groups are mutually exclusive, it can be determined that some grids have no dots

For convenience, it can be divided into two groups:

(1) A group formed by a single dot, for example, this (5) level will eventually have 2 such groups

A group of single dots whose eight neighbors do not place any dots

(2) For a group of n (n>1) dots, if the direction of this group is determined (the positions of all the dots in the group may not be determined, but the positions of 2 dots have been determined, the direction can be determined to be horizontal or vertical), then among the eight neighbors of each dot, the 6 neighbors that are not in the row and column of the group will not place a dot

The dots marked with black triangles are marked here, and 6 of its neighbors do not place dots. Naturally, those beyond the boundary are simply ignored.

Next, according to the processing of extremely large numbers:

At last:

(6)

   

(7)

   

(8)

   

(9)

   

(10)

   

(11)

   

(12)

   

(13)

   

(14)

   

(15)

   

(16)

   

(17)

   

(18)

   

(19)

   

(20)

   

(21)

   

Note that although there are only 2 final states of the lattice, if it is a hinted lattice, then in addition to the lattice itself, it also knows the situation of its neighbors.

In fact, it is an extension of "Method 3: Mutual Exclusion of Groups".

That is to say, from the beginning, it can be determined that:

Method 4: Optional Groups

If a row (column) is close to fully deterministic but not fully deterministic, an optional group limit can be considered

For example, in this level, there is only a 1*4 group, and there is no 1*3 group, so the fourth row must be a 1*4 group

Here we continue to use "Method 4: Optional Groups" and combine it with "Method 3: Mutual Exclusion of Groups"

Now there are only 2 1*2 groups and 2 1*1 groups left

If the 6th row is a 1*2 group, then the 1st and 2nd rows need to put 3 groups, which is obviously impossible.

So the 6th row must be 2 1*1 groups, the 1st and 2nd rows must be 2 1*2 groups, and one horizontal and one vertical

So the answer comes out, because of the existence of symmetry, the answer is not unique

(22)

   

(23)

   

(24)

   

(25)

   

(26)

   

(27)

   

(28)

   

(29)

   

(30)

First, use method one, two, three

Method 5: Enumeration of large group positions

Consider how to put the longest group and enumerate all possible cases

For example, in this level, the 1*3 group must be placed vertically, and in the 1st or 3rd or 6th column

If it is in the 1st or 6th column, it can be obtained quickly according to the method 123, which is unsolvable

If it is in column 3, the solution can be quickly obtained according to method 123

So far, 4*4, 5*5, and 6*6 have all been cleared.

There is a larger chessboard in the back, but I have already summarized the required methods, which are just more computationally intensive.

If the calculation is too large, it can be solved by programming. My code is in my other blog: Battleship series

Guess you like

Origin blog.csdn.net/nameofcsdn/article/details/122905939