Abigail wrote:
> I too get two solutions, and if one is ambiguous due
to a * b * c, the
> other is too, due to a + b + c. I'm not using base-3
counting, but I'm
> using recursion:
I played with Bernie's try, and Abigail's, and also
extended them somewhat, to handle other operators,
target values, and digit sets.

It seemed obvious to try adding a zero to the digit
set, though some of the results would be trivially
"+0" the 1..9 set.

I also tried this list of operators:

@ops = ( "", " + ", " * ", " - ", " / ", " % ", " **
", " << ", " >> ", " ^ ", " | ", " ~ " );

Bernie's solution would stop after several minutes,
with "Out of memory". ??? Must be that the garbage
collection isn't happening. I checked the resources as
it ran again, and it was using up 20M after just a few
minutes, and continued to rise steadily.

So the recursive solution seems to handle the larger
problem space more readily, as each substring is kept
around until all its variations are evaluated. But
with the iterative solution, each unique substring is
created, piecemeal, for each variation. Probably an
order of magnitude worse when the garbage collector is
on strike. But the recursive version eventually does
the same.

BTW, how to make garbage collection run? I'm using
5.005_03 built for sun4-solaris, though I could try it
out on 5.6.0. Or do I have a completely different
issue?

-QM


=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quantum Mechanics: The dreams stuff is made of

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

Reply via email to