From: Harry Kakueki Date: 2007-06-10T23:32:26+09:00 Subject: Re: [QUIZ] Mexican Blanket (#127) On 6/8/07, Ruby Quiz wrote: > > So the challenge is to make a pattern generator to generate the patterns as seen > in the ASCI and picture. It should, or rather NEEDS to, contain the Mexican flag > > # My HTML version prints a blanket in color. # It is quick and dirty HTML that could certainly # be improved but it is viewable. # This makes a 200x100 blanket. # It looks like this http://www.kakueki.com/ruby/q127.html # Code Start outs = File.new("./q127.html","w") colors = "GWRBYRGRRGRYBRWG" ahash = {} ahash.store("G",""+"o" + "") ahash.store("W",""+"o" + "") ahash.store("R",""+"o" + "") ahash.store("B",""+"o" + "") ahash.store("Y",""+"o" + "") unp = "aXaXaXaXaa" (1...colors.length).each do (1..4).each {|y| unp<<"X"<<"Xa"*(5-y)<<"a"<<"Xa"*y} unp << "a" end row = colors.unpack(unp) row.map! {|x| ahash[x] } outs.puts "" 200.times do outs.print row[0..99].join outs.print "
\n" row.shift end outs.puts "" outs.close # Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/