Say I have a grid that looks something like this:
0 1 2 3 
4 5 6 7
Imagine that we have a w by h grid, where the tiles are numbered starting at 1 in the top left corner. Imagine someone else has stored the values w (for width) and h (for height), that they have read in from a text file. You have access to these stored values, as long as you call them w and h. Write a program to return: the row number of a tile number given by the user. Use integer division, //, which returns only a whole number and truncates any remainder. Start counting rows at row 0.
sum = ((t - 1) // h) + 1 answers the question if the tiles start at 1, but I can't figure it out when the tiles start at 0.
You just divide the tile number by the number of tiles in a row w: row = t//w
To get the column do: col = t%w
I assume both row and column start at zero. If not, just add 1 where you need.
Figuring out a Row of a Tile number in Python