From: w_a_x_man Date: 2010-09-06T09:05:21+09:00 Subject: Re: Is my code unelegant? On Sep 5, 4:49 pm, Mark Walker wrote: > Is the attached code too messy to be considered "good"? > > I can't figure out if I created too many variables. > > I'm just now learning Ruby, and I just can't figure out if that's bad > code. > > Attachments:http://www.ruby-forum.com/attachment/5007/romannumerals1.rb > > -- > Posted viahttp://www.ruby-forum.com/. def old_roman n [1000,500,100,50,10,5,1]. map{|d| quot, n = n.divmod(d); quot }. zip( %w(M D C L X V I) ). map{|n,c| c * n}.join end puts "Enter a number and I'll convert " + "it to the older Roman Numerals!" puts old_roman( gets.to_i )