fork(2) download
  1. require 'set'
  2.  
  3. a = [1, 2, 3, 4, 5, 6]
  4.  
  5. r = Set.new(
  6. a.permutation.map{|p|
  7. Set.new(
  8. p.each_slice(2).map{|s|
  9. Set.new(s)
  10. }
  11. )
  12. }
  13. )
  14.  
  15. r.each { |s|
  16. p s.map(&:to_a)
  17. }
Success #stdin #stdout 0.06s 7564KB
stdin
Standard input is empty
stdout
[[1, 2], [3, 4], [5, 6]]
[[1, 2], [3, 5], [4, 6]]
[[1, 2], [3, 6], [4, 5]]
[[1, 3], [2, 4], [5, 6]]
[[1, 3], [2, 5], [4, 6]]
[[1, 3], [2, 6], [4, 5]]
[[1, 4], [2, 3], [5, 6]]
[[1, 4], [2, 5], [3, 6]]
[[1, 4], [2, 6], [3, 5]]
[[1, 5], [2, 3], [4, 6]]
[[1, 5], [2, 4], [3, 6]]
[[1, 5], [2, 6], [3, 4]]
[[1, 6], [2, 3], [4, 5]]
[[1, 6], [2, 4], [3, 5]]
[[1, 6], [2, 5], [3, 4]]