I spent the morning trying to find an easy function (x,y) -> n that would number the patches like this 

[![enter image description here](https://i.stack.imgur.com/co0Y4.png)](https://i.stack.imgur.com/co0Y4.png)

I was not successful. Do any of Y'all have any experience or suggestions?