--Apple-Mail-1--900007194 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Begin forwarded message: > From: <Tait_Pollard / doh.state.fl.us> > Date: June 26, 2006 2:58:06 PM CDT > To: <submission / rubyquiz.com> > Subject: Please Forward: Ruby Quiz Submission > --Apple-Mail-1--900007194 Content-Transfer-Encoding: quoted-printable Content-Type: application/octet-stream; x-unix-mode=0666; name="pascal.rb" Content-Disposition: attachment; filename=pascal.rb #Copyright=20Tait=20Pollard=202006=0D=0A=0D=0Arows=3DARGV[0].to_i=0D=0A= init,tri,space=3D[1],[1],""=0D=0A#iterate=20through=20creating=20rows=20= one=20less=20than=20total=20number=20of=20rows=0D=0A(rows-1).times=20do=0D= =0A=20=20cur_row,chngd_row,p1,p2=20=3D[],"",0,0=0D=0A=20=20init.each=20= {|x|=20p2,p1=3Dp1,x;=20cur_row<<(p2+p1)}=0D=0A=20=20init=3Dcur_row.dup=0D= =0A=20=20init<<1=0D=0A=20=20#after=20doing=20the=20calulations=20format=20= the=20rows=20with=20spaces=20between=20the=20numbers=20and=20concatenate=20= each=20row=20into=20a=20string=0D=0A=20=20cur_row.each=20do=20|x|=20=0D=0A= =20=20=20=20inter_space,x=3D"=20=20=20=20=20",x.to_s=0D=0A=20=20=20=20= case=20x.length=0D=0A=20=20=20=20=20=20when=201:=20=0D=0A=20=20=20=20=20=20= when=202:=20inter_space.chop!=0D=0A=20=20=20=20=20=20when=203:=20= 2.times{inter_space.chop!}=0D=0A=20=20=20=20=20=20when=204:=20= 3.times{inter_space.chop!}=0D=0A=20=20=20=20=20=20else=20= 4.times{inter_space.chop!}=0D=0A=20=20=20=20end=0D=0A=20=20=20=20= chngd_row<<x<<inter_space=0D=0A=20=20end=0D=0A=20=20= tri<<(chngd_row<<"1")=0D=0Aend=0D=0A#then=20format=20each=20row=20by=20= appending=20spaces=20to=20make=20it=20isoceles=20instead=20of=20left=20= justified=0D=0A((tri[tri.length-1].length)/2+3).times=20{space<<"=20"}=0D= =0A#then=20print=20the=20triangle=20to=20the=20screen=0D=0Atri.each=20= {|x|=203.times{space.chop!};=20puts=20(space+x.to_s)}= --Apple-Mail-1--900007194 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-1--900007194--