Given a square grid of side length N and m objects, can I design a 1-1 relationship between each object and a unique set of coordinates in that 2-D plane?
Imagine the context being something like storing objects in a hashmap of id to object and needing to calculate the L1 norm / Manhattan distance between any two objects quickly.
My initial thought was to use the mod operator and floor division, e.g. if we have $10$ objects and a $5$ by $5$ grid, maybe the unique location of object 7 will be $(25 \% 7, 25 // 7)$ = $(4, 3)$?
I'm less interested in an answer than I am in the thinking / creative process used to come up with a solution, and how to prove the answer is correct or disprove such a function exists.
Thank you!
The problem with your idea is that the values may fall outside the square. Object $1$ will be at $(0,10)$ and object $9$ will be at $(7,2)$, both outside your $5 \times 5$ square. The simplest approach is to use the side of the square as the denominator, so object $n$ goes at $(n\%N,n//N)$. This just puts them in the first columns as far as you need to go.