[QUIZ] Grid Folding (#63)

My solution, performs all the extra credits.


It's basically: get a stack of 2d arrays, chop them in half, rotate them
around and plonk them on top. The key bit was probably figuring out that
you could just rotate the entire piece of paper, fold one way and then
rotate it back, so you don't have to deal with the headaches of figuring
out how each fold will mutate the arrays. I also added in an
optimisation to keep track of the previous rotation so I didn't have to
burn cycles constantly rotating it back to the original orientation.
Once I was done I sat down and wrote out each fold individually, but it
ended up being slower than rotate and fold (I eventually optimised it to
be slightly faster, but I preferred the simpler code of the rotate

Unfolding wasn't very hard either, once you'd had a look at some stacks
just prior to the last fold. If there was a difference of one between
one of the rows on either side it was a left or right fold, otherwise it
was a top or bottom fold (depending on which layer had the higher
numbers). Did the same rotation magic to prevent headaches on figuring
out the unfolding algorithyms.