|
|
|
|
143
|
|
143
|
|
144
|
|
144
|
|
145
|
|
145
|
|
146
|
-## Laboratory Session
|
|
|
|
|
146
|
+## Laboratory Session:
|
147
|
|
147
|
|
148
|
### Exercise 1 - Square Grid
|
148
|
### Exercise 1 - Square Grid
|
149
|
|
149
|
|
150
|
Suppose that the robot is currently in the upper left room (northwest) of a **square** space of rooms, i.e. the space contains the same number of rows and columns of rooms (like the one in Figure 1). Design an algorithm that allows the robot to compute the number of rooms that there are in the grid.
|
150
|
Suppose that the robot is currently in the upper left room (northwest) of a **square** space of rooms, i.e. the space contains the same number of rows and columns of rooms (like the one in Figure 1). Design an algorithm that allows the robot to compute the number of rooms that there are in the grid.
|
151
|
|
151
|
|
152
|
-**Instructions**
|
|
|
|
|
152
|
+#### Instructions
|
153
|
|
153
|
|
154
|
1. Load the project `CountingSquares` into `QtCreator`. There are two ways to do this:
|
154
|
1. Load the project `CountingSquares` into `QtCreator`. There are two ways to do this:
|
155
|
|
155
|
|
|
|
|
|
169
|
|
169
|
|
170
|
### Exercise 2 - Rectangular Grid
|
170
|
### Exercise 2 - Rectangular Grid
|
171
|
|
171
|
|
172
|
-**Instructions**
|
|
|
|
|
172
|
+#### Instructions
|
173
|
|
173
|
|
174
|
1. Suppose that now the robot is in the upper left room (northwest) of a **rectangular** space (not necessarily square) of rooms. Design an algorithm so the robot can compute the number of rooms in the grid.
|
174
|
1. Suppose that now the robot is in the upper left room (northwest) of a **rectangular** space (not necessarily square) of rooms. Design an algorithm so the robot can compute the number of rooms in the grid.
|
175
|
|
175
|
|
|
|
|
|
181
|
|
181
|
|
182
|
### Exercise 3 - Rectangular Grid, Random Position
|
182
|
### Exercise 3 - Rectangular Grid, Random Position
|
183
|
|
183
|
|
184
|
-**Instructions**
|
|
|
|
|
184
|
+#### Instructions
|
185
|
|
185
|
|
186
|
1. Suppose that now the robot starts its task in any of the rooms in a **rectangular** grid (not necessarily square). Design an algorithm so the robot can compute the number of rooms there are in the grid.
|
186
|
1. Suppose that now the robot starts its task in any of the rooms in a **rectangular** grid (not necessarily square). Design an algorithm so the robot can compute the number of rooms there are in the grid.
|
187
|
|
187
|
|
|
|
|
|
195
|
|
195
|
|
196
|
### Exercise 4 - Pyramid Grid, Random Position
|
196
|
### Exercise 4 - Pyramid Grid, Random Position
|
197
|
|
197
|
|
198
|
-**Instructions**
|
|
|
|
|
198
|
+#### Instructions
|
199
|
|
199
|
|
200
|
1. Suppose that now the robot starts its task in any of the rooms in a grid shaped like a pyramid. Design an algorithm so the robot can compute the number of rooms there are in the grid.
|
200
|
1. Suppose that now the robot starts its task in any of the rooms in a grid shaped like a pyramid. Design an algorithm so the robot can compute the number of rooms there are in the grid.
|
201
|
|
201
|
|