Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mirror of a grid
#1
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
Reply
#2
Ok?

What have you tried so far?
Reply
#3
I don't know where to start with this one
Reply
#4
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...?
...
Reply
#5
Very similar, for others reading: https://python-forum.io/Thread-Neighbors-of-a-grid
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020