From: Atsuhiro Teshima Date: 2008-01-30T07:33:09+09:00 Subject: Re: Making Change (#154) Hi, I'm Atsuhiro. this is the first time I contribute to Ruby-forum. I find one solution for Ruby-Quiz154. the following is my solution (To tell the truth, I have only one-month programming experience and Ruby is the first programming language I choose.So, I'll glad if you point out some problem in my solution.) class Making_change $change = [] def make_change(amount,coins=[25,10,5,1]) @coing = coins if amount < 0 print "amount should be a positive integer \n" exit end coins.each do |i| if amount >= i $change << i amount = amount-i redo elsif amount == 0 return $change else next end end end end a = Making_change.new p a.make_change(52) # => [25,25,1,1] p a.make_change(-30) # => amount should be a positive integer -- Posted via http://www.ruby-forum.com/.