No idea what the desired output is (No ruby here).
Making 1 change to the perl code, gives me 3 lines of
output:
24 = (3 * (5 - 6))
24 = (6 / (1 - (3 / 4)))
24 = ((5 - 6) * 3)
While the 1st and the 3rd line are junk the 2nd is at least one (the?) solution.
I got there by substituting the code construction ( sub {...}) in the recursive
poss2 call by a mere $f, reasoning that what is constructed as
sub {
my($v3, $s3) = @_;
&$f($v3, $s3);
}
just looks like a wrapper to the input sub.
Does that help in any way?
Of course, I have to admit, I do not understand the algorithm (at the moment; but still trying to figure that part out), nor do I know ruby and can comment on your transforming the iterators ("yield") to perl closures :-/
Hoping to learn more, when you resolve the case...
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|