--Apple-Mail-5-850635044 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset -ASCII; formatðïwed Jason Bailey wrote: > for key, value in @data > count, num um.divmod(value) > reply << (key * count) > end That's neat, I approached it solely as a parsing problem, not a mathematical one. My solution is a tad longer, but it works (I think) :) Tim --Apple-Mail-5-850635044 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode77; name uby_quiz_22.rb" Content-Disposition: attachment; filename by_quiz_22.rb #!/usr/bin/env ruby module RomanNumerals BASICS 'I', 'V', 'X'0, 'L'0, 'C'00, 'D'00, 'M'000 } def self.convert( n ) (48..57) n[0] ? arabic_to_roman( n ) : roman_to_arabic( n ) end def self.roman_to_arabic( n ) total, previous , 0 n.to_s.split(//).reverse.each do |numeral| current ASICS[ numeral.upcase ] total + revious total - * current if current < previous previous urrent end total + revious return total end def self.arabic_to_roman( n ) numerals, tens, basic ], 1, BASICS.invert n.to_s.split(//).collect { |i| i.to_i }.reverse.each do |digit| numerals.unshift case digit when 2, 3 then basic[ tens ] * digit when 4 then basic[ tens ] + basic[ tens * 5 ] when 9 then basic[ tens ] + basic[ tens * 10 ] when 6, 7, 8 then basic[ tens * 5 ] + basic[ tens ] * ( digit - 5 ) when 1, 5 then basic[ tens * digit ] end tens ens * 10 end return numerals.to_s end end if ARGV.empty? ARGV.push( $stdin.read.chomp ) else ARGV.collect! { |file| IO.read( file ) } end ARGV.collect! do |input| input.split("\n").collect { |line| RomanNumerals.convert( line ) }.join("\n") end $stdout.write ARGV.join("\n")+"\n" --Apple-Mail-5-850635044 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset -ASCII; formatðïwed --Apple-Mail-5-850635044--