From: Josh Cheek Date: 2010-02-25T21:23:31+09:00 Subject: Re: Help on algorithm to calculate combinations --000e0cd23d8468949104806bd598 Content-Type: text/plain; charset=ISO-8859-1 Sorry, computer lagged and I hit 'send' rather than clicking in the window to edit. Here is a solution I meant to post, which has the correct inflections http://pastie.org/842110 def people_in_room(occupants) for men in 0..occupants for children in 0..occupants - men yield men , children end end end puts "in a room with 4 people, you could occupy it in the following ways:" people_in_room 4 do |men,children| to_print = Array.new to_print << "#{men} #{ men == 1 ? 'man' : 'men' }" unless men.zero? to_print << "#{children} #{ children == 1 ? 'child' : 'children' }" unless children.zero? puts to_print.join(' ') end --000e0cd23d8468949104806bd598--