-- YZCbaV32inTLJhquHRh
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Primary "Ah Ha" was deciding to make the digit
patterns 15 charaters (3 col * 5 rows).
Then simply a matter of determining which segment
to use for each space.
Looking forward to seeing other answers.
Vance
-- YZCbaV32inTLJhquHRh
Content-Disposition: attachment; filename=rq14
Content-Type: application/x-ruby; name=rq14
Content-Transfer-Encoding: 7bit
#! /bin/env ruby
s ' # space
u -' # underline
p |' # pipe
# use 15 pseudo segments per digit
cmap
[ s, u, s, p, s, p, s, s, s, p, s, p, s, u, s ], # 0
[ s, s, s, s, s, p, s, s, s, s, s, p, s, s, s ], # 1
[ s, u, s, s, s, p, s, u, s, p, s, s, s, u, s ], # 2
[ s, u, s, s, s, p, s, u, s, s, s, p, s, u, s ], # 3
[ s, s, s, p, s, p, s, u, s, s, s, p, s, s, s ], # 4
[ s, u, s, p, s, s, s, u, s, s, s, p, s, u, s ], # 5
[ s, u, s, p, s, s, s, u, s, p, s, p, s, u, s ], # 6
[ s, u, s, s, s, p, s, s, s, s, s, p, s, s, s ], # 7
[ s, u, s, p, s, p, s, u, s, p, s, p, s, u, s ], # 8
[ s, u, s, p, s, p, s, u, s, s, s, p, s, u, s ], # 9
]
#process args
sz
if ARGV[0] '-s'
ARGV.shift
sz RGV.shift.to_i
end
sz if sz < 1 || sz > 10 # sanity check
unless ARGV.length > 0
puts "Usage: $0 [-s <siz>] <number>"
exit
end
#select digits from input string ...
digits RGV[0].split(//).find_all{|c| ('0'..'9').include?(c)}
# grid bounds
maxx 3 + sz) * digits.length - 1
maxy + sz * 2
(0..maxy).each {|y|
ro * (y/(sz+1)) + (y%(sz+1) 0 ? 0 : 3) # row offset
(0..maxx).each {|x|
dndx /(3+sz) # which digit in string
t %(3+sz) # tmp value
cndx o # index into cmap t 0
cndx o + 1 if t > 0 # t in 1..sz
cndx o + 2 if t 1+sz # last column of digit
cndx if t 2+sz # spc btwn nums 1st psuedo seg always ' '
print cmap[digits[dndx].to_i][cndx] # char at x,y coord
}
print "\n" # next row
}
-- YZCbaV32inTLJhquHRh--