Position of squares on a checkerboard from a sequence of numbers I want to position squares on a checkerboard in such a way that they fill the square they are on.

How do I calculate the position of one of those orange squares such that $f(i) = x,y$ coordinate, $i$ being the number of the orange square starting from $0$.
Also, the size of the checkerboard is not definite, I need the pattern to repeat for any size of the checkerboard horizontally and vertically.
With a checkerboard height of 5 instead of 4.

 A: You have to play with how many times you have reached $5.$ They way to do this is with division, so taking ceils is the right approach. The row is just $\left \lfloor \frac{i}{5}\right \rfloor,$ the column depends on which row are we. It is $5\times \left \lfloor \frac{\left \lfloor \frac{i}{5}\right \rfloor}{5}\right \rfloor +i\pmod 5.$ This gives you
$$f(i)=\left (5\times \left \lfloor \frac{\left \lfloor \frac{i}{5}\right \rfloor}{5}\right \rfloor +\left(i\pmod 5)\right )\, ,\, 
\left \lfloor \frac{i}{5}\right \rfloor\right ).$$
here the columns and rows are indexed starting at $0.$
The code in sage looks like:
A = [[0 for i in range(0,10)] for j in range(0,10)]
for i in range(0,50):
    x = i//5
    y = 5*(x//5) + i%5
    A[x][y]=i+1
for i in range(0,10):
    print(A[i])

Edit:
Your new formula will have to have a period of $2$ that alternates it.
The code for your new pattern looks like
  A = [[0 for i in range(0,20)] for j in range(0,20)]
    for i in range(0,25*8):
        x = i//10
        tal = (i%10)//5
        retal = (i//50)%2
        y = 5*retal + 5*tal+ i%10
        A[x][y]=i+1
    for i in range(0,20):
        print(A[i])

Edit 2:
For any height and even width, the following does what you want
h = 4
w = 8
A = [[0 for i in range(0,5*w)] for j in range(0,5*h)]
for i in range(0,(h*w*25)/2):
    ww = ceil(w/2)*5
    x = i//ww
    tal = (i%ww)//5
    retal = (i//(ww*5))%2
    y = 5*retal + 5*tal+i%ww
    if x<h*5 and y<5*w:
        A[x][y]=1+i
for i in range(0,5*h):
    print(A[i])

The explanation is the same as before, so I am not sure what is unclear or why you keep changing the size instead of generalizing it. Why is the odd width case different? How to fix it?
