Note: This is a daunting problem for anyone who likes logical problems and so on.
The value of each location on a rectangular height H and two-dimensional grid grid of width is either 0
1
or 2
. Initially, there is a 0
everywhere on the grid, except that at each location of four edges, which is initially a 2
.
Then consider an arbitrary route of the adjacent (horizontal or vertical) grid spaces, the path starts at a 2
and on a different 2
ends. There is a 1
everywhere with the path.
Divides the path grid into two "regions" of the 0
space. An object that is subject to unspecified 0
space depends on the "sector" in which the object is not included, it must be completely filled with 2
.
Define an algorithm that defines the spacing that should be created with 2
0
, values ( 0
An array (list) of 1
, or 2
) has been given in the grid in the values in the grid, from top to bottom, and then in other words, array index 0 But the value of the top-left position in the element grid (initially, a 2
) occurs. The element on index 1 is the value of the place in the grid, which is in the left column, second to the top and above. The element present in index h is the value of the place in the grid in the top row, but the second from the left, and so forth.
Once the algorithm is over and the empty "sector" is completely filled with Whatever is able to understand this for me, many thanks. It is not in any special programming language; In fact, the pseudo code or just English is enough thanks again! If you have any questions, just leave a comment and I will specify what to specify. I think a basic algorithm will get a job: This will work for any grid configuration, Unless the two Edit: to save you or save two - small changes, 2
s, the same algorithm should be sufficient to perform the same process again. The second (and) time, the path is still drawn from 2
to a blank space of 2
to 0
, but the "grid" is smaller Is because the second can not be touched by the 2
s surrounded by the second 2
(since the path is with 0 ).
0
, and then start filling a flood out there, with any other number in the 0
area, assume that 3
- This will label one of your "sectors". 0
, and flood, fill this code 4
0
. 2
, and you have done 0
fields that are disconnected from each other; Therefore re-implementing the same algorithm is fine at any time.
2
and leave another area alone (because it already has 0
-Throwout). 2
, and then again the code will be filled with the 0
.
Comments
Post a Comment