s

Code Golf: Seven-Segment Displays

Sep 08, 2008

Here is my submission for the Seven-Segment Displays challenge. Code size: 292 bytes.

x=gets.chop.split ''
a=' ### '
b='#    '
c='    #'
d='#   #'
e=' '*5
f='  '
g=[a]
h=[d]*3
i=[e]
j=[c]*3
k=[b]*3
l=g+h
m=g+j
n=m+g
y={0=>l+i+h+g,1=>i+j+i+j+i,2=>n+k+g,3=>m+n,4=>i+h+m+i,5=>g+k+n,6=>g+k+l+g,7=>m+i+j+i,8=>l+l+g,9=>l+n}
9.times{|i|puts x.collect{|n|y[n.to_i][i]+f}.join.chop.chop}

Tagged: rubycode golf