Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: (Golf) LED Sign

by petral (Curate)
on Jun 10, 2001 at 05:49 UTC ( [id://87252]=note: print w/replies, xml ) Need Help??

in reply to (Golf) LED Sign

179 chars:
sub led{ ($b=pop)=~y/0-9.\-\0-~/\0-\cK/d; join$/, map{join$", ($"x4,'X ',' X','X X','X'x4)[(/./g)[unpack'C*',$b]] }424434444400, (322231123300)x2, 324444424404, (321222323200)x2, (424x4)-4,"" } print led @ARGV ? shift : "19QQ86\t-- \@0134.72x-0(?)";
(Using hex conversion for the string (and to delete unwanted characters! ) and an array slice of an array slice to generate the lines.)

(Change the trailing ' ~ ' to a ' '(" ÿaut "?) to reject 8-bit chars too -- I wasn't sure how it would travel inside code tags.)

update:  or 172 chars w/o argument checking and putting the '-' first:
($b=pop)=~y/-0-9./\0-\cK/;join$/, map{join$",('X ',$"x4,' X','X X','X'x4)[(/./g)[unpack'C*',$b]]} 142443444441,(132223002331)x2,432444442441,(132022232321)x2,1 .424x4 ,""

Replies are listed 'Best First'.
Re^2: (Golf) LED Sign
by tadman (Prior) on Jun 11, 2001 at 05:02 UTC
    The conversion to low-ASCII for index uses was something that I had considered while writing my first take. I would've used ord instead of unpack. However, using unpack to double as both ord and split is truly devious.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://87252]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-06-25 05:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    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.