I have a 2D array grid where each cell has a number in it, i would need a alghorithm that returns me the value of that cell depending on the X, Y position (0, 0 is bottom left)
This is the grid in question, it can be infinite in size and "grows" in such a way that it always adds first the right outer edge, starting from the bottom and then goes to the left until it comes back to the edge. For example the next full "square" of this itteration would be:
What i would need a function that given x, y positions would return me that number. Example:
getValue(0, 0) = 0 getValue(0, 1) = 1 getValue(0, 2) = 4 getValue(1, 0) = 3 getValue(3, 3) = 12 getValue(6, 6) = 42 getValue(6, 0) = 48
The function should ofcourse calculate this value in some fashion and not get it from some premade grid of finite size, since the input of those value could be very large.