From: email55555 email55555 Date: 2005-01-10T05:50:35+09:00 Subject: Re: [SOLUTION] Ruby Quiz #14 LCD Numbers ( solution #2 ) Thanks Jannis Harder found the bug. It is still 349 bytes program: ( the bug is on "u[x==1?2:5]<0", it should be "u[x==1?2:5] wrote: > Wow ... Jannis Harder's solution is really short .... > > This is base on Jannis Harder's solution (398 bytes) ... > We could make Jannis Harder's solution even shorter, for example: > (1) y.map!{|v|v<<32} could rewrite to y.map!{|v|v< save 1 byte > (2) many ?: code like ?x: y could rewrite to ?x:y ( no need space > before y) ==> save n bytes > (3) and ... (see my code about my idea to make it even shorter ) > > Here is my even shorter solution ( base on Jannis Harder's solution ) > it is 349 bytes ( 49 bytes shorter than Jannis Harder's solution ) > > s=$*.index("-s");s=(s ?$*.slice!(s,2)[1].to_i: 2) > i=$*.join.split("").map{|x|x.to_i} > d,="7krtt1r30v/s".unpack("m")[0].unpack("B*") > f=" " > a,b=f*s,f+"-"*s+f > c,e,o="|",a+f+f,49 > y=([0]*5).map{""} > i.each{|z|u=d[z*7,7] > 3.times{|x|y[x*2]<<(u[x*3] [1,3].each{|x|y[x]<<(u[x==1?1:4] y[1,1]*=s > y[2+s,1]*=s > puts y >