```James Gray wrote:
> The three rules of Ruby Quiz:

=] Here is my solution.

You will forgive the extension of the file, but this quiz was an excuse
for me to learn and play with new things, like OptParse. I rather
uploaded it in a pastie.

My solution handles extra credits, and my own suggestions except
parenthesis precedence. With full options, it runs very slow, because
the number of permutations and combinations grows n!

As an example, a run with these options

\$ ruby quiz119.rb --o +,-,*,/ --f --m --v --d 1234567

produces

123+4+5*0.67 = 130.35
123+4+5*6.7 = 160.50
0.123+4+5*67 = 339.12
.....

17 times target reached, out of 217224 equations tested:
123*4-56*7 = 100.00
1+23+4+5+67 = 100.00
1+2+34+56+7 = 100.00
1+23-4+56/0.7 = 100.00
12+0.3*45*6+7 = 100.00
12+3*4.5*6+7 = 100.00
12+3*45*0.6+7 = 100.00
-1-234+5*67 = 100.00
1*23*4+56/7 = 100.00
-1/2+34-0.5+67 = 100.00
-1+0.2*34*5+67 = 100.00
-1+2*3.4*5+67 = 100.00
-1+2*34*0.5+67 = 100.00
1*23*4-5+6+7 = 100.00
-1-2+34*5-67 = 100.00
-1/2+3/0.4/5*67 = 100.00
-1/2+3/4/0.5*67 = 100.00
Total run time: 50.844356 seconds

Trying to do that for digits 1 to 9 is a craziness @.@

Here is the file:

http://pastie.caboo.se/52702

--
Posted via http://www.ruby-forum.com/.

```