# Pythagoras Would Puke

This week a colleague pointed out this comment from an Ask Reddit:

danceswithwolves 62 points 4 days ago* [-]
I went to a job interview and the interviewer told me I would get the job (my first full time job ever) if I could answer this math question which is supposedly a middle school grade question. I had no clue how to solve it so I’m jobless now and suffering. To this day I never figured out the answer. http://img691.imageshack.us/img691/2192/mathv.png (The lines are curved if that makes a difference)

Basically the problem asks you to find the area of a sort-of-square, inside a square of side 4. Each corner of the outer-square is joined to the adjacent one by an arc of angle pi/2 radians (90 degrees) of radius 4. The sort-of-inner-square is outlined by the four crossing arcs. See the link above, or the picture below for a diagram.

Normally when faced with puzzles of this sort I try and pretend I’m too busy to figure them out. Partly because I’m belligerent, bordering rude, and partly because I know I’m a bit dumb. If my life depended on getting the answer I’d be dead already. So it was a strange thing indeed that I found myself working on and actually enjoying this particular puzzle. I did, of course, out of all of my colleagues get to the answer last.

It then occurred to me that I could regain some cool by trying to draw a better diagram (than the one in the comment) using the Common Lisp vector drawing package Vecto. It was actually a lot easier than I thought it was going to be and came out quite nice, the result is here: the code is here.

After arriving at our respective numerical answers some bright-spark said that it should be possible to verify our results using Monte-Carlo methods. I thought about this for a bit and then concluded that it would actually be quite easy to do, especially in Lisp where functions are first class objects. You can see the code here.

As fun as it was to find the answer by Monte-Carlo it was a bit of a waste of time since I could have just as easily subdivided the area into a grid of tiny squares and then counted the ones that were inside and outside the shape. This would have been simpler to code and it would have been more accurate too.

Pythagoras would probably have known that of course.