Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I think my idea is a "cul-de-sac" but this is a little bit shorter (7 char.).
sub w{for$;(1005,924745596,341831533){say map{$;>>$_&1?/../?'|':_:$"}m +ap{$_+20,$_,$_+10}$_[0]=~/./g}}
-- edit: Some explanations about 1005,924745596,341831533
# How to find (1005,924745596,341831533) triplet? # use warnings "nmmt"; # Not My Mother Tongue # _ _ _ _ _ _ _ _ <- line1 #| | | _| _||_||_ |_ ||_||_| <- line2 #|_| ||_ _| | _||_| ||_| _| <- line3 # # line 1 ($l1) is : " _ _ _ _ _ _ _ _ " # 0 1 2 3 4 5 6 7 8 9 # with " "=>0 and "_"=>1, it becomes a binary integer # each digit is encoded with three bits: # 0=> 010 # 1=> 000 # 2=> 010 # ... # 9 (line 3) => 011 (or 0b110 with lower bit at right] # Order of bits is modified to save some bytes (golf-oriented): # in line 1, first and last bits are always zeros (put them at left) # in line 3, there are more zeros for last bit than first bit # This way, the position of 3 bits to encode a digit (abc) # is NOT "0(a),1(b),2(c)" [cba: lower bit right] # # higher lower # 2 1 # 0 0 0 # ... but "20,0,10" (a000000000c000000000b) # ^ ^ ^ # Funny fact: # With the "natural order" the triplet is (1029120,972944241,106939731 +7) and... # 1069397317 is a prime number http://www.wolframalpha.com/input/?i=10 +69397317 # and 341831533=577592429 my $cl=<<SEVSEG; _ _ _ _ _ _ _ _ | | | _| _||_||_ |_ ||_||_| |_| ||_ _| | _||_| ||_| _| SEVSEG my ($l1,$l2,$l3)=split/\n/,$cl; my $i=0; $b=20; my @add=(-20,10,11); # bit position sequence : 20 , 0 , 10 , 21 , 1 , 11,... # -20 10 11 ($a+=$_*2**$b),$b=$b+$add[$i++%3] for map{0+(/[|_]/)}split//,$l1; print "line 1 ->$a"; $a=0; $i=0; $b=20; print "\n"; ($a+=$_*2**$b),$b=$b+$add[$i++%3] for map{0+(/[|_]/)}split//,$l2; print "line 2 ->$a"; $a=0; $i=0; $b=20; print "\n"; ($a+=$_*2**$b),$b=$b+$add[$i++%3] for map{0+(/[|_]/)}split//,$l3; print "line 3->$a"; print "\n";

In reply to Re^3: Golf: Seven segment display by brx
in thread Golf: Seven segment display by kikuchiyo

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 having a coffee break in the Monastery: (5)
    As of 2024-07-18 05:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      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.