James Koppel wrote: > I opted to take the lazy route this time, and just print out the names > of the cards. However, I did leave in code for another counting system. > > (Before anyone critiques the presence of cartesian_product, I am well > aware of Array#product; I just haven't gotten around to upgrading to 1.9 > yet.) > (...) > def cartesian_product(first, *rest) > return first if rest == [] > rest = cartesian_product(*rest) > combs = block_given? ? nil : [] > first.each do |v1| > rest.each do |v2| > if block_given? > yield v1+v2 > else > combs << (v1 + v2) > end > end > end > combs > end > (...) Your code resulted in this error: "card_count_trainer1.rb:50:in `*': no implicit conversion from nil to integer (TypeError)" Cartesian products were discussed recently in http://www.ruby-forum.com/topic/95519 . William James came up with the remarkable def cart_prod( *args ) args.inject([[]]){|old,lst| new = [] lst.each{|e| new += old.map{|c| c.dup << e }} new } end wich is included in my personal "wow.rb". regards, Siep -- Posted via http://www.ruby-forum.com/.