*This is a guest post by semi-regular guest author, mathematician-turned-maths-teacher Andrew Stacey.*

I like having something mathematical to think about for times when I’m, for example, waiting in a queue to get into the supermarket. Annie Perkin’s Math Art Challenge has been a good source of such of late. These are a series of mathematically-inspired artistic activities, ranging from designing celtic knots to constructing origami polyhedra and everything in between.

My eye was caught by one on sandpiles – I’ll explain exactly what they are in a moment. One feature that made it attractive was that it was quite simple to write a program to generate diagrams. I find that the maths that interests me usually comes from looking at variations, and for that I need to generate a lot of examples. Doing them by hand quickly becomes laborious. So I whipped up a program (which I later converted to an online version) and ran it a few times to see what happened.