Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: (Golf) LED Sign

by srawls (Friar)
on Jun 08, 2001 at 05:59 UTC ( [id://86818]=note: print w/replies, xml ) Need Help??


in reply to (Golf) LED Sign

Well, I sure wish I could beat that by my own code, but I couldn't even come close. I can improve on yours though. First of all: in a golf, you needn't use my and pre-declare variables. Second, I don't understand the need for this statement:
$_=join'',map{"$_\n"}@l[0,1,1,2,3,3,4];
Why not just use this
$_=join$/,@l[0,1,1,2,3,3,4];
Well, here's your improved code, it checks in at 223 chars:
sub f{ @c=qw[00700 00001 00000 75557 11111 71747 71717 55711 74717 74757 71111 75757 75717]; map{$l[$i++%5].=join'',(unpack("B8",chr)=~/(...)$/)[0,1,1,2],$"} map{split//,$c[ord($_)-45]}split//,pop; $_=join$/,@l[0,1,1..4]; tr/01/ X/;$_ }


The 15 year old, freshman programmer,
Stephen Rawls

Replies are listed 'Best First'.
Re^2: (Golf) LED Sign
by tadman (Prior) on Jun 08, 2001 at 06:05 UTC
    To clarify: In one case, you have something which is, to abbreviate, XnXnXnXn versus XnXnXnX, where the former has a newline at the end, and the second does not. It's a minor thing, I know, and mostly cosmetic.

    As a result, it doesn't wrap the last line around, leaving something like:
    shell% perl srawls X XXX XXX XXX X X X X X X X X X X X X X XXX XXX X X X X X X X X XXX XXX XXX shell%
    I like your art deco twist on the "font". Very retro.
      As a result, it doesn't wrap the last line around, leaving something like:
      ... X XXX XXX XXX shell%
      Configure your shell prompt to be "X", and you get free punctuation.

      As a result, it doesn't wrap the last line around, leaving something like:

      Yep, it's a golf, so I was trying to shave off as many chars as possible; good observation though.

      I like your art deco twist on the "font". Very retro.

      Funny you mention that, It happened completely by accident, when I was trying to shorten the code : )

      The 15 year old, freshman programmer,
      Stephen Rawls

        Your "optimization" of (.)(.)(.) to (...) has the effect of making the letters only 3 wide instead of 4, since the duplicator [0,1,1,2] isn't working. Moving to a more compact representation would eliminate the need for this altogether.
        As a result, it doesn't wrap the last line around...
      $_=join$/,@l[0,1,1..4],'';
      fixes that.

        p

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2025-06-22 14:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.