From: Glenn Parker Date: 2005-01-13T03:16:29+09:00 Subject: Re: [SOLUTION] LCD Numbers (#14) --------------030909030706050101080809 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Apologies for a very late entry. I was on the road last week, but I didn't peek at anybody else's solutions. No golfing here, just straightforward raster output. -- Glenn Parker | glenn.parker-AT-comcast.net | --------------030909030706050101080809 Content-Type: text/plain; name="lcd.rb.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="lcd.rb.txt" #!/usr/bin/env ruby -w require 'getoptlong' $size = 2 GetoptLong.new( ["-s", GetoptLong::REQUIRED_ARGUMENT] ).each do |opt, val| case opt when '-s': $size = val.to_i end end $digits = ARGV[0] || '' # 0- # 1| 2| # 3- # 4| 5| # 6- SEGMENTS = [ # 0 1 2 3 4 5 6 [ '-', '|', '|', ' ', '|', '|', '-' ], # 0 [ ' ', ' ', '|', ' ', ' ', '|', ' ' ], # 1 [ '-', ' ', '|', '-', '|', ' ', '-' ], # 2 [ '-', ' ', '|', '-', ' ', '|', '-' ], # 3 [ ' ', '|', '|', '-', ' ', '|', ' ' ], # 4 [ '-', '|', ' ', '-', ' ', '|', '-' ], # 5 [ '-', '|', ' ', '-', '|', '|', '-' ], # 6 [ '-', ' ', '|', ' ', ' ', '|', ' ' ], # 7 [ '-', '|', '|', '-', '|', '|', '-' ], # 8 [ '-', '|', '|', '-', ' ', '|', '-' ], # 9 ] def horz(w) $digits.each_byte do |d| mark = SEGMENTS[d - ?0][w * 3] print ' ' + (mark * $size) + ' ' + (' ' * $size) end print "\n" end def vert(w) $size.times do $digits.each_byte do |d| mark1 = SEGMENTS[d - ?0][(w * 3) + 1] mark2 = SEGMENTS[d - ?0][(w * 3) + 2] print mark1 + (' ' * $size) + mark2 + (' ' * $size) end print "\n" end end horz(0) vert(0) horz(1) vert(1) horz(2) --------------030909030706050101080809--