Created
October 1, 2008 10:28
-
-
Save andrehjr/14062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_support' | |
require 'set' | |
a = [ 'q1', 'q2', 'q3', 'q4' , 'q5', 'q6'] #, 'q3', 'q4', 'q5'] #, 'q3', 'q4' ] | |
new_test = [] | |
a.each_with_index do |item, index| | |
for_now = a.from(index.succ) | |
for_now.each do |item2,index2| | |
others = (for_now - item2.to_a); | |
new_test << [item, item2].join("-") | |
for_now.inject([]) do |memo, other| | |
new_test << [item, others - other.to_a].flatten.join("-") | |
new_test << [item, (others - memo)].flatten.join("-") | |
new_test << [item, memo].flatten.join("-") | |
memo << other | |
end | |
end | |
new_test << for_now.join("-") | |
end | |
new_test << a.join("-") | |
puts new_test.size | |
puts Set.new(new_test).to_a.sort.inspect | |
puts Set.new(new_test).to_a.size | |
puts new_test.size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment