laziness, impatience, and hubris PerlMonks

### Re^2: Golf: Seven segment display

by PrakashK (Pilgrim)
 on Jan 23, 2012 at 20:30 UTC ( #949520=note: print w/replies, xml ) Need Help??

in reply to Re: Golf: Seven segment display
in thread Golf: Seven segment display

Applying the ...=~/./g trick (which you already used once inside the map) again:

sub w{for\$;(-2..0){say map{substr'   _ _|_  |_| |',2*ord(('u\$SR,Z]dmj'=~/./g)[\$_])>>-3*\$;&14,3}\$_[0]=~/./g}}

Replies are listed 'Best First'.
Re^3: Golf: Seven segment display
by brx (Pilgrim) on Jan 24, 2012 at 15:34 UTC
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

a few obvious optimizations:

say map\$'&2**\$_?\$_>9?'|':_:\$",map{2 .\$_,\$_,1 .\$_}split!//,"@_"for 1005,924745596,341831533

I'd say the use of \$' is less than obvious. Nice work btw.

The shortest solution I know (not my own creation):

```for\$;(0..2){say map{substr'   | |_|_ _ _|',vec('0123456789abcdef',\$;.\$
+_,4),3}"@_"=~/./g}

where '0123456789abcdef' is to be substituted with "\x09\x99\x90\x99\x99\x13\xBB\x75\x17\x55\x15\xB7\xB1\x15\xB5". When the \x codes are replaced with the actual characters, it comes out two characters shorter than the solution above. (Not very elegant, though.)

Create A New User
Node Status?
node history
Node Type: note [id://949520]
help
Chatterbox?
 [Discipulus]: i dream to restart kung-fu someday: i studied only 2-3 years of win-chun, tang-lang and a bit of shaolin.. the better preparation ever! [Discipulus]: ah and hung-har too

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-11-22 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In order to be able to say "I know Perl", you must have:

Results (327 votes). Check out past polls.

Notices?