Mirror of a grid - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Mirror of a grid (/thread-5301.html) |
Mirror of a grid - beatyjl - Sep-27-2017 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 RE: Mirror of a grid - nilamo - Sep-27-2017 Ok? What have you tried so far? RE: Mirror of a grid - beatyjl - Sep-27-2017 I don't know where to start with this one RE: Mirror of a grid - nilamo - Sep-27-2017 Start with the simplest possible problem, and slowly build on that until it matches the requirements. For this, let's start with a 2x2 grid always. Once you can solve for that, make sure it can solve for 3x3. After THAT, let the user tell you how big the grid is, and make sure it still works. >>> grid = [[0, 1], [2, 3]] >>> # now what...? ... RE: Mirror of a grid - nilamo - Sep-27-2017 Very similar, for others reading: https://python-forum.io/Thread-Neighbors-of-a-grid |