Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: (Golf) LED Sign

by petral (Curate)
on Jun 10, 2001 at 05:49 UTC ( #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
Node Status?
node history
Node Type: note [id://87252]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2017-04-30 01:53 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (534 votes). Check out past polls.