Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I opted for the "abuse regex" approach (because it's fun, and you can do it incrementally one s/// at a time until it works):

#!/usr/bin/perl # http://perlmonks.org/?node_id=1121552 use strict; use warnings; for my $y ( 1..25 ) { local $_ = tile(5,$y); /1$/ and !/-/ and print "success 5,$y\n"; } sub tile { my ($w, $h) = @_; my $wm1 = $w - 1; local $_ = ( '-' x $w . "\n" ) x $h; s/-/1/; 1 while # print("$_\n"), s/1..{$w}\K-/1/s || s/1\n.*\K-(?=\n)/2/ || s/1(?=.*$)\K-/4/ || s/2.{$wm1}\K-/2/s || s/2.{$wm1}\n\K-/1/ || s/-(?=2.*$)/3/ || s/-(?=..{$w}3)/3/s || s/^.*\K-(?=3)/2/ || s/-(?=.{$wm1}\n3)/4/ || s/-(?=.{$wm1}4)/4/s || s/^.*4\K-/1/ || s/-(?=.{$w}4\n)/3/s; return $_; }

which prints

success 5,1 success 5,3 success 5,7 success 5,9 success 5,11 success 5,13 success 5,17 success 5,19 success 5,21 success 5,23

Sure looks like multiple solutions exist.


In reply to Re: [OT (though it might involve some Perl programming)] One for the weekend. (Updated: significant typo!) by Anonymous Monk
in thread [OT] One for the weekend. (Updated: Answer posted!) by BrowserUk

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, 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
  • 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.
  • Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others studying the Monastery: (4)
    As of 2024-09-14 04:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      The PerlMonks site front end has:





      Results (21 votes). Check out past polls.

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.