email55555 email55555
1/9/2005 8:51:00 PM
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]<o", typo
error "o" instead of "0")
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]<o ?e:b)<<f}
[1,3].each{|x|y[x]<<(u[x==1?1:4]<o ?f:c)+a+(u[x==1?2:5]<o ?f:c)<<f}}
y[1,1]*=s
y[2+s,1]*=s
puts y
On Sun, 9 Jan 2005 15:13:25 -0500, email55555 email55555
<email55555@gmail.com> 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<<f} ==> 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]<o ?e:b)<<f}
> [1,3].each{|x|y[x]<<(u[x==1?1:4]<o ?f:c)+a+(u[x==1?2:5]<0 ?f:c)<<f}}
> y[1,1]*=s
> y[2+s,1]*=s
> puts y
>