Friday Puzzler: Math in English

For today's puzzler, I thought of a simple little thing that would make you work your string parsing part of the brain. I started out in Perl and absolutely love mucking around with strings, so I thought, why not share this love with everyone else? (Remind me to tell you about the contract work I did for Netscape back in 98 or so that was - basically - one big perl script to update their web site.)

This puzzle is rather simple. Build a form that will accept math questions in English. So for example:

one plus two

You only need to support numbers from zero to ten. You can report the answer as either a number or a word. You need to support "plus", "minus", "multiply", "divide". Bonus points if you catch a division by zero error. Bonus points if you ignore, and don't get tripped by, stuff at the end, like "is?"

I write these posts for free — if they're useful to you, you can buy me a coffee. It helps more than you'd think.

As always, the prize is nothing, which is great since your tax burden on nothing will be roughly 33% of the value of nothing. You have 5 minutes to solve this, but if you spend more, I won't tell anyone. If you get fired doing this, I need someone to help dig up a mail post so I'd be happy to give you a new job.

Enjoy!