Do you know where your variables are? | |
PerlMonks |
Re^3: Happy 2006by Limbic~Region (Chancellor) |
on Jan 11, 2006 at 18:16 UTC ( [id://522521]=note: print w/replies, xml ) | Need Help?? |
Perl Mouse,
No, just each term in the expression is evaluated independently. This is how we did similar puzzles in school. The program works as follows: Algorithm::Loops generates all the permutation of operators needed and then the numbers are zipped forming a single string. This is the point where eval $string would produce the same results as your code. Instead, I break each term apart and keep a running total of the value which is returned. In my opinion, what would make the puzzle much more interesting would be to require single expression evaluation as your solution does but prohibit the use of eval $string. Here is my original solution modified accordingly though it is quite slow and a bit obfu now. Thanks for the puzzle.
Cheers - L~R
In Section
Cool Uses for Perl
|
|