Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
For those interested, this is the code I used to compare the new solution to the original one:
#!/usr/bin/perl use warnings; use strict; use feature 'state'; use integer; use Test::More; my (@s_rev, @s); my ($l, $k, $d, $b, $c, $j, $h, $b1, $lt, $kt, $i); try() for 1 .. 1000; done_testing(); sub new { ## Insert your code here return ($l, $k, $d, $b, $c, $j, $h, $b1, $lt, $kt, $i, \@s_rev, \@ +s); } sub try { init(1); my @r0 = orig(); init(0); my @r1 = new(); is_deeply(\@r0, \@r1); } sub init { state @keep; $_ = shift; if ($_) { ($l, $k, $d, $b, $c, $j, $h, $b1, $lt, $kt, $i, @s_rev) = map { rand 8 } 1 .. 12 + rand 20; @s = (0 .. 3 + rand 20); @keep = ($l, $k, $d, $b, $c, $j, $h, $b1, $lt, $kt, $i, [@s_re +v], [@s]); } else { ($l, $k, $d, $b, $c, $j, $h, $b1, $lt, $kt, $i) = @keep; @s = @{ $keep[-1] }; @s_rev = @{ $keep[-2] }; } } sub orig { if ($l < $k) { if ($s_rev[$d + 1] == 0 && $k - 2 > 0){ $s_rev[$d + 1] = $k - 2; } $h = $s[$b] == 0 ? 0 : $s[$b] - 1; $s[$b1] = max($k, $lt); $c = 2; $j++; } elsif ($l > $k) { if($s[$b + 1] == 0 && $l - 2 > 0){ $s[$b + 1] = $l - 2; } $h = $s[$b] == 0 ? 0 : $s[$b] - 1; $s[$b1] = max($l, $kt); $c = 1; $i++; } else { if($s[$b+1] == 0 && $k - 2 > 0){ $s[$b+1] = $k-2; } $s[$b1] = max($k, $lt); $h = 0; $c = 0; } return ($l, $k, $d, $b, $c, $j, $h, $b1, $lt, $kt, $i, \@s_rev, \@ +s); } sub max{ my ($x, $y) = @_; return $x > $y ? $x : $y; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

In reply to Re: reducing the number of lines by choroba
in thread reducing the number of lines by baxy77bax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (8)
    As of 2014-07-25 23:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (175 votes), past polls