### Re: Golf: Seven segment display

by kikuchiyo (Monk)
 on Jan 18, 2012 at 12:38 UTC ( #948539=note: print w/replies, xml ) Need Help??

in reply to Golf: Seven segment display

Better approach:

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

Replies are listed 'Best First'.
Re^2: Golf: Seven segment display
by PrakashK (Pilgrim) on Jan 23, 2012 at 20:30 UTC

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}}

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

Create A New User
Node Status?
node history
Node Type: note [id://948539]
help
Chatterbox?
 LanX Gesundheit! :) talexb wonders about dividing developers in those born before the Unix timestamp of zero .. and after. Spoiler: I'm before. chacham remebers I am a mad scientist [stevieb]: talexb I'm after by a few years, but we can still be friends because you live in my hometown ;)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-08-18 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (303 votes). Check out past polls.

Notices?