CS 1110: Introduction to Programming Spring 2017 In-class exercise — Pseudocode |
Purpose: Practice problem solving and write pseudocode
For this exercise, you may work alone or with 1-2 of your neighbors. Consider the following problems and write pseudocode to solve the problems.
Imagine that the user specifies the width of a grid, as well as a tile.
You will return either "True" or "False" depending on
whether or not the tile is along the diagonal of the square grid.
For example, on a 7x7 grid,
assuming the tile numbers (starting at the top-left corner)
are 1, 2, 3, ..., 49
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | ||||||
15 | ||||||
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
36 | ||||||
43 |
row = (tile - 1) // width
col = (tile - 1) % width
Imagine that the user specifies the width of a grid, as well as a tile.
You will return either "True" or "False" depending on
whether or not the tile is along the edge of grid.
For example, on a 7x8 grid,
assuming the tile numbers (starting at the top-left corner)
are 1, 2, 3, ..., 56
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | ||||||
15 | ||||||
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
36 | ||||||
43 | ||||||
50 |
row = (tile - 1) // width
col = (tile - 1) % width
Imagine that the user specifies the width and height of a grid, as well as a tile.
You will return either "True" or "False" depending on
whether or not the tile is in the middle row of the grid.
For example, on a 7x8 grid,
assuming the tile numbers (starting at the top-left corner)
are 1, 2, 3, ..., 56
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | ||||||
15 | ||||||
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
36 | ||||||
43 | ||||||
50 |
row = (tile - 1) // width
col = (tile - 1) % width
Imagine that the user specifies with width and height of a grid.
You will return a string that represents all ordered tiles that make up the
corners of the grid, with three tiles to a corner.
You will return a string where each tile has a space after it
(this will simplify your algorithm).
For example, on a 7x10 grid,
assuming the tile numbers (starting at the top-left corner)
are 1, 2, 3, ..., 70
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 14 | |||||
15 | ||||||
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | ||||||
36 | ||||||
43 | ||||||
50 | ||||||
57 | 63 | |||||
64 | 65 | 66 | 67 | 68 | 69 | 70 |
row = (tile - 1) // width
col = (tile - 1) % width