Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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":



  • 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.
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 admiring the Monastery: (5)
As of 2024-05-18 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found