fork(2) download
  1. def gen(b)
  2. (1..(b - 1)).inject([[b]]) {|s, i| s + gen(b - i).collect{|j| ([i] + j).sort}}.sort
  3. end
  4.  
  5. arr_uniq = gen(6).uniq.reject { |a| a.uniq.count != a.count }
  6.  
  7. print arr_uniq
  8. puts '', arr_uniq.count
  9.  
Success #stdin #stdout 0.03s 9720KB
stdin
Standard input is empty
stdout
[[1, 2, 3], [1, 5], [2, 4], [6]]
4