global number x=0
global number y=0
for "x" from 0 to 15-2
for "y" from 0 to 3-1
-- set x to loopindex("x")
-- set y to loopindex("y")
-- if array.at(x,y)=array.at(x+1,y)
-- or array.at(x,y)=array.at(x+1,(y+1)%3)
-- or array.at(x,y)=array.at(x+1,(y+2)%3)
-- -- ... there is the same match on consecutive weeks.
Probably the algo at that point would be:
1. load intial array values.
2. swap stuff around
3. check if there are any repeat matches from one week to the next.
4. if there are repeats go back to 2 and try again.
5. otherwise you have a good layout.
That could succeed first try or never succeed.
You probably can do something smarter by knowing that there are ony five different weeks of pairs.
Then it simplifies to a string a sting of numbers
123451234512345
Then just scramble those around, and then fill the weeks in the array form that. Then all that would be left is to swap items around in each column.
I mean the algo would be the same, just simpler to do.