I’m not sure why we can’t map a position in a big grid to a position in a small grid by doing:
X = Math.floor(bigX / bigXMax * smallXMax)
Is there some magic here I’m not seeing?
X = Math.floor(bigX / bigXMax * smallXMax)
Is there some magic here I’m not seeing?
We've not got the whole picture though, but you don't need CS training to know that a loop within a loop within a loop within a loop is a bad idea.
And even for non-regular grids, as long as they're somewhat regular (like timezones), you can narrow it down to just a handful candidates that a linear scan will then solve instantly.