ci_202208_programming_2
Author
Description (English)
Suppose that we have a maze on a square board with

When a sequence of numbers is stored, we store a character string in a file as follows.
2,0,13,0,1,6,8,1
This denotes the sequence of numbers where the 0th number is 2, the 1st number is 0, the 2nd number is 13, ... All the elements in a sequence are integers more than or equal to zero.
(1) A sequence of numbers {sequence.txt.
Write down the 216-th element
(2) Make a maze on p.txt. Its elements are either 0, 1, 2, or 3.
- Put walls along the outer limits of the maze.
- For every pair of
and , where and , - put the upper wall for cell
when is 0, - put the left wall for cell
when is 1, - put the lower wall for cell
when is 2, - put the right wall for cell
when is 3.
- put the upper wall for cell
Here,
(2-a) Write down on the answer sheet the existence of the upper, lower, left, and right walls for cells
(2-b) Write down on the answer sheet the number of the L-shaped corner cells in this maze. A cell is a L-shaped corner cell when it is surrounded with exactly two walls directly jointed to form L-shape.
(3) Make a maze on
-
Put the upper, lower, left, and right walls for all the cells so that all the cells are closed cells.
-
Set the current position to the start cell.
-
Select a closed cell N in the maze among the upper, lower, left, and right cells adjacent to the current position. Then remove the wall separating the selected cell N and the current position. Move the current position to that cell N. Repeat this again.
When selecting the cell N, refer to the sequence of numbers
stored in file neighbor.txt. The elements of this sequence is either 0, 1, 2, or 3.Suppose that the current position is
. Let be the -th element of the sequence . For given , when is 0, select the upper cell of the cell . When it is 1, select the left cell. When it is 2, select the lower cell. When it is 3, select the right cell for N, respectively. Here, . Choose for selecting N. is an integer more than or equal to zero and also is the minimum integer such that a closed cell is selected for N. When no cell is selectable for N, select a cell C. The cell C must not be a closed cell. Furthermore, at least one adjacent cell to C must be a closed cell. Move the current position to that cell C. When a necessary element of the sequence
does not exist, select a cell C and move the current position to that cell C. When selecting the cell C, refer to the sequence of numbers
stored in file cell.txt. Its elements are integers less than 40 and more than or equal to zero.Suppose that the current position is
. Select a cell such that is minimum among the cells satisfying the requirements for C. Here, and is an integer more than or equal to zero. When no cell is selectable for C, the maze is completed. When a necessary element of the sequence
does not exist, the maze is also completed.
(3-a) Write down on the answer sheet the existence of the upper, lower, left, and right walls for cells
(3-b) Write down on the answer sheet the number of the L-shaped corner cells in this maze. A cell is a L-shaped corner cell when it is surrounded with exactly two walls directly jointed to form L-shape.
(3-c) Find the longest straight passages in this maze and write their length down on the answer sheet. Furthermore, write down the number of such longest passages on the answer sheet. For example, the path between cells
(3-d) We can reach the goal of this maze when proceeding through the maze by always keeping one wall on the left-hand side in the direction of the move. Write down on the answer sheet the number of the cells visited on the way to the goal. When the same cell is visited twice, that cell is counted only once. Include the start and the goal cells in the cells visited on the way. At first, the upper wall of the start cell is on the left-hand side in the direction of the move.