I noticed your repo here https://github.com/kjytay/IMO after doing something similar myself: http://olivernash.org/2017/08/05/visualising-imo-results/index.html

I know this is shameless self-promotion but I thought there was a reasonable chance you’d be interested!

]]>(2n+1)*(2n+2)/2

cells (2n+1st triangular number) and each of the 2n+1 numbers appears in it an equal number of times, i.e. n+1 times (divide the above by 2n+1). For any number k, let d(k) be the number of times k is on the diagonal. Then, in the top right, it’s on d(k) and off n+1-d(k) times. Since every off-diagonal instance is duplicated in the bottom left, that means each number appears in total

d(k) + 2*[n+1-d(k)] = 2n + 2 – d(k)

times. Since we also know each number appears in total 2n+1 times, that means d(k) = 1.

]]>X_n+1 = tan(X_n – pi/8)

which explains the period-8 (and shows a way to construct other variants)

The puzzle I had before was

]]>