Ah, shame! That destroys the symmetry I was exploiting and so requires two lots of not quite identical code :(

sub interleave { my( $a, $b ) = qw[ a b ]; my( $as, $bs ) = @_; return $a x $as . $b x $bs unless $as >1 and $bs; if( $as > $bs ) { ++$bs; my $aPerB = int( $as / $bs ); my $aRem = $as - $bs * $aPerB; my @as = ( $a x $aPerB ) x $bs; my $n = 0; $as[ $n ] .= $a, $as[ - ++$n ] .= $a, $aRem -= 2 while $aRem > + 1; $as[ @as / 2 ] .= $a if $aRem > 0; return join $b, @as; } else { --$as; my $bPerA = int( $bs / $as ); my $bRem = $bs - $as * $bPerA; my @bs = ( $b x $bPerA ) x $as; my $n = 0; $bs[ $n ] .= $b, $bs[ - ++$n ] .= $b, $bRem -= 2 while $bRem > + 1; $bs[ @bs / 2 ] .= $b if $bRem > 0; return $a . join( $a, @bs ) . $a; } } __END__ C:\test>624887 -S=1 -N=50 4a 5b: abbababba 4a 7b: abbabbbabba ----------- 4a 13b: abbbbabbbbbabbbba 4a 14b: abbbbbabbbbabbbbba 4a 15b: abbbbbabbbbbabbbbba 4a 16b: abbbbbabbbbbbabbbbba 4a 17b: abbbbbbabbbbbabbbbbba 4a 18b: abbbbbbabbbbbbabbbbbba 4a 19b: abbbbbbabbbbbbbabbbbbba ----------- 13a 4b: aaabaabaaabaabaaa 14a 4b: aaabaaabaabaaabaaa 15a 4b: aaabaaabaaabaaabaaa 16a 4b: aaabaaabaaaabaaabaaa 17a 4b: aaaabaaabaaabaaabaaaa 18a 4b: aaaabaaabaaaabaaabaaaa 19a 4b: aaaabaaaabaaabaaaabaaaa -----------

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^5: Spreading out the elements by BrowserUk
in thread Spreading out the elements by Anonymous Monk

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.