In the comments section of a recent
Atwood
post, commentor Paul Jungwirth (search for the name as I can't find
comment permalinks) posted about a problem from a
perl
mailing list that he would give potential hires. This post is not
about the blog post but about the problem from the comments section.
**The Problem** (from the mailing list): Consider the following string: 1
2 3 4 5 6 7 8 9 = 2002 The problem is to add any number of addition &
multiplication operations wherever you'd like on the left such that in
the end you have a valid equation. So for example if it gets you to a
solution you can have: 12 * 345 + 6 … if that works as part of your
solution [it's much too big: 4146]. Bearing in mind that multiplication
takes higher precedence than addition, what is the solution? My answer
generator can be found
here
in Erlang. I liked the problem because it is in the vein of
Project Euler. The eval/1 is a slightly
modified version of this one on
TrapExit.