Sep-27-2017, 04:55 PM
Imagine that the user specifies with width and height of a grid, and a tile in that grid. Find the "mirror-mirror" of that tile, that is, if you folded the grid in half, and then folded it in half again, the tile that the original tile overlaps is its mirror-mirror (think of folding a sheet of paper in half, and then folding it in half again along the other axis). For example, for a 7x10 grid:
1 2 3 4 5 6 7
8 9 14
15 16
22 23 24 25 26 27 28
29 32
36 40
43 44 48
50 56
57 63
64 65 66 67 68 69 70
the mirror-mirror of tile 27 would be tile 44.
You may use the following formulas in your solution as needed:
row = (tile - 1) // width
column = (tile - 1) % width
1 2 3 4 5 6 7
8 9 14
15 16
22 23 24 25 26 27 28
29 32
36 40
43 44 48
50 56
57 63
64 65 66 67 68 69 70
the mirror-mirror of tile 27 would be tile 44.
You may use the following formulas in your solution as needed:
row = (tile - 1) // width
column = (tile - 1) % width