ผลต่างระหว่างรุ่นของ "01204212/homework/maze"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
(หน้าที่ถูกสร้างด้วย ': ''This is part of 01204212'' In this homework you will write a maze solver. The following is a sample maze. You start at O and...')
 
 
(ไม่แสดง 3 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน)
แถว 2: แถว 2:
  
 
In this homework you will write a maze solver.  The following is a sample maze.  You start at O and your exit is at X.
 
In this homework you will write a maze solver.  The following is a sample maze.  You start at O and your exit is at X.
 +
 +
Let's consider a sample input and output first.  Here is the input:
  
 
<pre>
 
<pre>
 +
11 17
 
#################
 
#################
 
#O........#.....#
 
#O........#.....#
แถว 17: แถว 20:
 
</pre>
 
</pre>
  
The output should be:
+
The first line of the input contains the number of rows and columns of the maze.  The maze will not be larger than 40 rows and 40 columns. The maze contains these 4 characters: '#' - walls, '.' - walkway, 'O' - staring point and 'X' - the exit.  You can move in 4 directions: up (^), right (>), down (v), and left (<). 
 +
 
 +
The output of the above input should be:
  
 
<pre>
 
<pre>
 +
34
 
#################
 
#################
 
#O>>>>>>>v#.....#
 
#O>>>>>>>v#.....#
แถว 32: แถว 38:
 
#################
 
#################
 
</pre>
 
</pre>
 +
 +
You should find the shortest way to reach the exit from the starting point.  The first line should contain the minimum number of steps.  Then the maze showing the path should be printed.  Use these characters to denote directions: ^, >, v, <.
 +
 +
== More examples ==

รุ่นแก้ไขปัจจุบันเมื่อ 04:21, 5 ธันวาคม 2559

This is part of 01204212

In this homework you will write a maze solver. The following is a sample maze. You start at O and your exit is at X.

Let's consider a sample input and output first. Here is the input:

11 17
#################
#O........#.....#
#########.#######
#...#...#.#.....#
#.#.#.#.#.##.##.#
#.#...#......#..#
#.#############.#
#..#....#.......#
#.##.#.##.#.#####
#....#....#....X#
#################

The first line of the input contains the number of rows and columns of the maze. The maze will not be larger than 40 rows and 40 columns. The maze contains these 4 characters: '#' - walls, '.' - walkway, 'O' - staring point and 'X' - the exit. You can move in 4 directions: up (^), right (>), down (v), and left (<).

The output of the above input should be:

34
#################
#O>>>>>>>v#.....#
#########v#######
#...#...#v#.>>>v#
#.#.#.#.#v##^##v#
#.#...#..>>>^#.v#
#.#############v#
#..#....#..v<<<<#
#.##.#.##.#v#####
#....#....#>>>>X#
#################

You should find the shortest way to reach the exit from the starting point. The first line should contain the minimum number of steps. Then the maze showing the path should be printed. Use these characters to denote directions: ^, >, v, <.

More examples