Paul Jungwirth wrote:
You have the numbers 123456789, in that order. Between each number, you must insert either nothing, a plus sign, or a multiplication sign, so that the resulting expression equals 2001. Write a program that prints all solutions. (There are two.)I think you meant 2002, not 2001.
(Just correcting for anyone else like me who obsessively tries to solve little “practice” problems like this one, and then hit Google when their result doesn’t match the stated answer. Damn, some of those Perl examples are ugly.)