set_partition 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +1 -0
- data/lib/set_partition.rb +8 -0
- data/lib/set_partition/array.rb +56 -0
- data/lib/set_partition/fixed_generator.rb +66 -0
- data/lib/set_partition/generator.rb +82 -0
- data/lib/set_partition/version.rb +3 -0
- data/set_partition.gemspec +24 -0
- data/spec/set_partition/array_spec.rb +75 -0
- data/spec/set_partition/fixed_generator_spec.rb +31 -0
- data/spec/set_partition/generator_spec.rb +47 -0
- metadata +112 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Teja Sophista V.R.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# SetPartition
|
2
|
+
|
3
|
+
Ruby implementation of [Partition of a Set](http://en.wikipedia.org/wiki/Partition_of_a_set) based on paper *Efficient Generation of Set Partitions* by [Michael Orlov](mailto:orlovm@cs.bgu.ac.il)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'set_partition'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install set_partition
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
set_partition = SetPartition::Generator.new 4
|
22
|
+
set_partition.start #=> [0,0,0,0]
|
23
|
+
set_partition.next #=> [0,0,0,1]
|
24
|
+
set_partition.next #=> [0,0,1,0]
|
25
|
+
|
26
|
+
set_partition = SetPartition::FixedGenerator.new 4, 2
|
27
|
+
set_partition.start #=> [0,0,0,1]
|
28
|
+
set_partition.next #=> [0,0,1,0]
|
29
|
+
set_partition.next #=> [0,0,1,1]
|
30
|
+
|
31
|
+
set_partition = SetPartition::Array.new [:a, :b, :c, :d]
|
32
|
+
set_partition.start #=> [[:a,:b,:c,:d]] # [0,0,0,0]
|
33
|
+
set_partition.next #=> [[:a,:b,:c], [:d]] # [0,0,0,1]
|
34
|
+
set_partition.next #=> [[:a,:b,:d], [:c]] # [0,0,1,0]
|
35
|
+
|
36
|
+
set_partition = SetPartition::Array.new [:a, :b, :c, :d], 2
|
37
|
+
set_partition.start #=> [[:a,:b,:c], [:d]] # [0,0,0,1]
|
38
|
+
set_partition.next #=> [[:a,:b,:d], [:c]] # [0,0,1,0]
|
39
|
+
set_partition.next #=> [[:a,:b], [:c,:d]] # [0,0,1,1]
|
40
|
+
|
41
|
+
set_partition = SetPartition::Array.new [:a, :b, :c, :d], 2
|
42
|
+
set_partition.to_a
|
43
|
+
#=>[
|
44
|
+
# [[:a,:b,:c], [:d]],
|
45
|
+
# [[:a,:b,:d], [:c]],
|
46
|
+
# [[:a,:b], [:c,:d]],
|
47
|
+
# [[:a,:c,:d], [:b]],
|
48
|
+
# [[:a,:c], [:b,:d]],
|
49
|
+
# [[:a,:d], [:b, :c]],
|
50
|
+
# [[:a], [:b,:c,:d]]
|
51
|
+
# ]
|
52
|
+
|
53
|
+
## TODO
|
54
|
+
- The Ruby Way
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module SetPartition
|
2
|
+
class Array
|
3
|
+
def initialize array, partition_size=nil
|
4
|
+
@array = array
|
5
|
+
@generator = if partition_size
|
6
|
+
FixedGenerator.new array.size, partition_size
|
7
|
+
else
|
8
|
+
Generator.new array.size
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def start
|
13
|
+
reify @generator.start
|
14
|
+
end
|
15
|
+
|
16
|
+
def end
|
17
|
+
reify @generator.end
|
18
|
+
end
|
19
|
+
|
20
|
+
def next
|
21
|
+
reify @generator.next
|
22
|
+
end
|
23
|
+
|
24
|
+
def prev
|
25
|
+
reify @generator.prev
|
26
|
+
end
|
27
|
+
|
28
|
+
def partition_size
|
29
|
+
@generator.size
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_a
|
33
|
+
[reify(@generator.start)].tap do |array|
|
34
|
+
while @generator.next
|
35
|
+
array.push reify @generator.current
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def current
|
41
|
+
reify @generator.current
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def reify partition
|
46
|
+
return unless partition
|
47
|
+
|
48
|
+
[].tap do |array|
|
49
|
+
partition.each_with_index do |partition_index, i|
|
50
|
+
array[partition_index] ||= []
|
51
|
+
array[partition_index].push @array[i]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module SetPartition
|
2
|
+
class FixedGenerator < Generator
|
3
|
+
def initialize length, partition
|
4
|
+
@partition = partition
|
5
|
+
super length
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
def initialize_first
|
10
|
+
@first = [0] * (@length - @partition)
|
11
|
+
|
12
|
+
(@length - @partition).upto(@length - 1) do |i|
|
13
|
+
@first[i] = i - (@length - @partition)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize_last
|
18
|
+
@last = 0.upto(@partition - 1).to_a
|
19
|
+
|
20
|
+
@partition.upto(@length - 1) do |i|
|
21
|
+
@last[i] = @partition - 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def next_partition
|
26
|
+
p = partition_length
|
27
|
+
|
28
|
+
(@length - 1).downto(1) do |i|
|
29
|
+
if (@current[i] < p - 1) && @current[i] <= @maximum[i - 1]
|
30
|
+
@current[i] = @current[i] + 1
|
31
|
+
@maximum[i] = [@maximum[i], @current[i]].max
|
32
|
+
|
33
|
+
(i + 1).upto(@length - (p - @maximum[i])) do |j|
|
34
|
+
@current[j] = 0
|
35
|
+
@maximum[j] = @maximum[i]
|
36
|
+
end
|
37
|
+
|
38
|
+
(@length - (p - @maximum[i]) + 1).upto(@length - 1) do |j|
|
39
|
+
@current[j] = @maximum[j] = p - (@length - j)
|
40
|
+
end
|
41
|
+
return
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def previous_partition
|
47
|
+
p = partition_length
|
48
|
+
|
49
|
+
(@length - 1).downto(1) do |i|
|
50
|
+
if @current[i] > 0 && (p - @maximum[i - 1] <= @length - i )
|
51
|
+
@current[i] = @current[i] - 1
|
52
|
+
@maximum[i] = @maximum[i - 1]
|
53
|
+
|
54
|
+
(i + 1).upto(i + (p - @maximum[i]) - 1) do |j|
|
55
|
+
@current[j] = @maximum[j] = @maximum[i] + j - i
|
56
|
+
end
|
57
|
+
|
58
|
+
(i + (p - @maximum[i])).upto(@length - 1) do |j|
|
59
|
+
@current[j] = @maximum[j] = p -1
|
60
|
+
end
|
61
|
+
return
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module SetPartition
|
2
|
+
class Generator
|
3
|
+
attr_reader :current
|
4
|
+
|
5
|
+
def initialize length
|
6
|
+
@length = length
|
7
|
+
initialize_first
|
8
|
+
initialize_last
|
9
|
+
start
|
10
|
+
end
|
11
|
+
|
12
|
+
def start
|
13
|
+
@current = @first.dup
|
14
|
+
@maximum = @first.dup
|
15
|
+
end
|
16
|
+
alias :rewind :start
|
17
|
+
|
18
|
+
def end
|
19
|
+
@current = @last.dup
|
20
|
+
@maximum = @last.dup
|
21
|
+
end
|
22
|
+
|
23
|
+
def next
|
24
|
+
return if @current == @last
|
25
|
+
next_partition
|
26
|
+
@current
|
27
|
+
end
|
28
|
+
|
29
|
+
def prev
|
30
|
+
return if @current == @first
|
31
|
+
previous_partition
|
32
|
+
@current
|
33
|
+
end
|
34
|
+
alias :previous :prev
|
35
|
+
|
36
|
+
def length
|
37
|
+
partition_length
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def initialize_first
|
42
|
+
@first = [0] * @length
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize_last
|
46
|
+
@last = 0.upto(@length - 1).to_a
|
47
|
+
end
|
48
|
+
|
49
|
+
def next_partition
|
50
|
+
(@length - 1).downto(1) do |i|
|
51
|
+
if @current[i] <= @maximum[i - 1]
|
52
|
+
@current[i] = @current[i] + 1
|
53
|
+
@maximum[i] = [@maximum[i], @current[i]].max
|
54
|
+
|
55
|
+
(i + 1).upto(@length - 1) do |j|
|
56
|
+
@current[j] = @current[0]
|
57
|
+
@maximum[j] = @maximum[i]
|
58
|
+
end
|
59
|
+
return
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def previous_partition
|
65
|
+
(@length - 1).downto(1) do |i|
|
66
|
+
if @current[i] > @current[0]
|
67
|
+
@current[i] = @current[i] - 1
|
68
|
+
@maximum[i] = @maximum[i] - 1
|
69
|
+
|
70
|
+
(i + 1).upto(@length - 1) do |j|
|
71
|
+
@current[j] = @maximum[j] = @maximum[i] + j - i
|
72
|
+
end
|
73
|
+
return
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def partition_length
|
79
|
+
@maximum[@length - 1] - @maximum[0] + 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'set_partition/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "set_partition"
|
8
|
+
spec.version = SetPartition::VERSION
|
9
|
+
spec.authors = ["Teja Sophista V.R."]
|
10
|
+
spec.email = ["tejanium@yahoo.com"]
|
11
|
+
spec.description = "Set Partition"
|
12
|
+
spec.summary = "Ruby implementation of http://en.wikipedia.org/wiki/Partition_of_a_set based on paper Efficient Generation of Set Partitions by Michael Orlov <orlovm@cs.bgu.ac.il>"
|
13
|
+
spec.homepage = "http://github.com/tejanium/set_partition"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'set_partition'
|
2
|
+
|
3
|
+
describe SetPartition::Array do
|
4
|
+
it "generate all possibility set forward" do
|
5
|
+
set_partition = SetPartition::Array.new [:a, :b, :c, :d]
|
6
|
+
|
7
|
+
set_partition.start.should eql [[:a,:b,:c,:d]] # [0,0,0,0]
|
8
|
+
set_partition.next.should eql [[:a,:b,:c], [:d]] # [0,0,0,1]
|
9
|
+
set_partition.next.should eql [[:a,:b,:d], [:c]] # [0,0,1,0]
|
10
|
+
set_partition.next.should eql [[:a,:b], [:c,:d]] # [0,0,1,1]
|
11
|
+
set_partition.next.should eql [[:a,:b], [:c], [:d]] # [0,0,1,2]
|
12
|
+
set_partition.next.should eql [[:a,:c,:d], [:b]] # [0,1,0,0]
|
13
|
+
set_partition.next.should eql [[:a,:c], [:b,:d]] # [0,1,0,1]
|
14
|
+
set_partition.next.should eql [[:a,:c], [:b], [:d]] # [0,1,0,2]
|
15
|
+
set_partition.next.should eql [[:a,:d], [:b, :c]] # [0,1,1,0]
|
16
|
+
set_partition.next.should eql [[:a], [:b,:c,:d]] # [0,1,1,1]
|
17
|
+
set_partition.next.should eql [[:a], [:b,:c], [:d]] # [0,1,1,2]
|
18
|
+
set_partition.next.should eql [[:a,:d], [:b], [:c]] # [0,1,2,0]
|
19
|
+
set_partition.next.should eql [[:a], [:b,:d], [:c]] # [0,1,2,1]
|
20
|
+
set_partition.next.should eql [[:a], [:b], [:c,:d]] # [0,1,2,2]
|
21
|
+
set_partition.next.should eql [[:a], [:b], [:c], [:d]] # [0,1,2,3]
|
22
|
+
|
23
|
+
set_partition.next.should be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "generate all possibility set forward with partition size" do
|
27
|
+
set_partition = SetPartition::Array.new [:a, :b, :c, :d], 2
|
28
|
+
|
29
|
+
set_partition.start.should eql [[:a,:b,:c], [:d]] # [0,0,0,1]
|
30
|
+
set_partition.next.should eql [[:a,:b,:d], [:c]] # [0,0,1,0]
|
31
|
+
set_partition.next.should eql [[:a,:b], [:c,:d]] # [0,0,1,1]
|
32
|
+
set_partition.next.should eql [[:a,:c,:d], [:b]] # [0,1,0,0]
|
33
|
+
set_partition.next.should eql [[:a,:c], [:b,:d]] # [0,1,0,1]
|
34
|
+
set_partition.next.should eql [[:a,:d], [:b, :c]] # [0,1,1,0]
|
35
|
+
set_partition.next.should eql [[:a], [:b,:c,:d]] # [0,1,1,1]
|
36
|
+
|
37
|
+
set_partition.next.should be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it "#to_a" do
|
41
|
+
set_partition = SetPartition::Array.new [:a, :b, :c, :d]
|
42
|
+
|
43
|
+
set_partition.to_a.sort.should eql [
|
44
|
+
[[:a,:b,:c,:d]], # [0,0,0,0]
|
45
|
+
[[:a,:b,:c], [:d]], # [0,0,0,1]
|
46
|
+
[[:a,:b,:d], [:c]], # [0,0,1,0]
|
47
|
+
[[:a,:b], [:c,:d]], # [0,0,1,1]
|
48
|
+
[[:a,:b], [:c], [:d]], # [0,0,1,2]
|
49
|
+
[[:a,:c,:d], [:b]], # [0,1,0,0]
|
50
|
+
[[:a,:c], [:b,:d]], # [0,1,0,1]
|
51
|
+
[[:a,:c], [:b], [:d]], # [0,1,0,2]
|
52
|
+
[[:a,:d], [:b, :c]], # [0,1,1,0]
|
53
|
+
[[:a], [:b,:c,:d]], # [0,1,1,1]
|
54
|
+
[[:a], [:b,:c], [:d]], # [0,1,1,2]
|
55
|
+
[[:a,:d], [:b], [:c]], # [0,1,2,0]
|
56
|
+
[[:a], [:b,:d], [:c]], # [0,1,2,1]
|
57
|
+
[[:a], [:b], [:c,:d]], # [0,1,2,2]
|
58
|
+
[[:a], [:b], [:c], [:d]] # [0,1,2,3]
|
59
|
+
].sort
|
60
|
+
end
|
61
|
+
|
62
|
+
it "#to_a with partition size" do
|
63
|
+
set_partition = SetPartition::Array.new [:a, :b, :c, :d], 2
|
64
|
+
|
65
|
+
set_partition.to_a.sort.should eql [
|
66
|
+
[[:a,:b,:c], [:d]], # [0,0,0,1]
|
67
|
+
[[:a,:b,:d], [:c]], # [0,0,1,0]
|
68
|
+
[[:a,:b], [:c,:d]], # [0,0,1,1]
|
69
|
+
[[:a,:c,:d], [:b]], # [0,1,0,0]
|
70
|
+
[[:a,:c], [:b,:d]], # [0,1,0,1]
|
71
|
+
[[:a,:d], [:b, :c]], # [0,1,1,0]
|
72
|
+
[[:a], [:b,:c,:d]] # [0,1,1,1]
|
73
|
+
].sort
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'set_partition'
|
2
|
+
|
3
|
+
describe SetPartition::FixedGenerator do
|
4
|
+
it "generate all possibility set forward" do
|
5
|
+
set_partition = SetPartition::FixedGenerator.new 4, 2
|
6
|
+
|
7
|
+
set_partition.start.should eql [0,0,0,1]
|
8
|
+
set_partition.next.should eql [0,0,1,0]
|
9
|
+
set_partition.next.should eql [0,0,1,1]
|
10
|
+
set_partition.next.should eql [0,1,0,0]
|
11
|
+
set_partition.next.should eql [0,1,0,1]
|
12
|
+
set_partition.next.should eql [0,1,1,0]
|
13
|
+
set_partition.next.should eql [0,1,1,1]
|
14
|
+
|
15
|
+
set_partition.next.should be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "generate all possibility set backward" do
|
19
|
+
set_partition = SetPartition::FixedGenerator.new 4, 2
|
20
|
+
|
21
|
+
set_partition.end.should eql [0,1,1,1]
|
22
|
+
set_partition.prev.should eql [0,1,1,0]
|
23
|
+
set_partition.prev.should eql [0,1,0,1]
|
24
|
+
set_partition.prev.should eql [0,1,0,0]
|
25
|
+
set_partition.prev.should eql [0,0,1,1]
|
26
|
+
set_partition.prev.should eql [0,0,1,0]
|
27
|
+
set_partition.prev.should eql [0,0,0,1]
|
28
|
+
|
29
|
+
set_partition.prev.should be_nil
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'set_partition'
|
2
|
+
|
3
|
+
describe SetPartition::Generator do
|
4
|
+
it "generate all possibility set forward" do
|
5
|
+
set_partition = SetPartition::Generator.new 4
|
6
|
+
|
7
|
+
set_partition.start.should eql [0,0,0,0]
|
8
|
+
set_partition.next.should eql [0,0,0,1]
|
9
|
+
set_partition.next.should eql [0,0,1,0]
|
10
|
+
set_partition.next.should eql [0,0,1,1]
|
11
|
+
set_partition.next.should eql [0,0,1,2]
|
12
|
+
set_partition.next.should eql [0,1,0,0]
|
13
|
+
set_partition.next.should eql [0,1,0,1]
|
14
|
+
set_partition.next.should eql [0,1,0,2]
|
15
|
+
set_partition.next.should eql [0,1,1,0]
|
16
|
+
set_partition.next.should eql [0,1,1,1]
|
17
|
+
set_partition.next.should eql [0,1,1,2]
|
18
|
+
set_partition.next.should eql [0,1,2,0]
|
19
|
+
set_partition.next.should eql [0,1,2,1]
|
20
|
+
set_partition.next.should eql [0,1,2,2]
|
21
|
+
set_partition.next.should eql [0,1,2,3]
|
22
|
+
|
23
|
+
set_partition.next.should be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "generate all possibility set backward" do
|
27
|
+
set_partition = SetPartition::Generator.new 4
|
28
|
+
|
29
|
+
set_partition.end.should eql [0,1,2,3]
|
30
|
+
set_partition.prev.should eql [0,1,2,2]
|
31
|
+
set_partition.prev.should eql [0,1,2,1]
|
32
|
+
set_partition.prev.should eql [0,1,2,0]
|
33
|
+
set_partition.prev.should eql [0,1,1,2]
|
34
|
+
set_partition.prev.should eql [0,1,1,1]
|
35
|
+
set_partition.prev.should eql [0,1,1,0]
|
36
|
+
# set_partition.prev.should eql [0,1,0,2]
|
37
|
+
set_partition.prev.should eql [0,1,0,1]
|
38
|
+
set_partition.prev.should eql [0,1,0,0]
|
39
|
+
set_partition.prev.should eql [0,0,1,2]
|
40
|
+
set_partition.prev.should eql [0,0,1,1]
|
41
|
+
set_partition.prev.should eql [0,0,1,0]
|
42
|
+
set_partition.prev.should eql [0,0,0,1]
|
43
|
+
set_partition.prev.should eql [0,0,0,0]
|
44
|
+
|
45
|
+
set_partition.prev.should be_nil
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: set_partition
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Teja Sophista V.R.
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
16
|
+
type: :development
|
17
|
+
name: bundler
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '1.3'
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
prerelease: false
|
32
|
+
type: :development
|
33
|
+
name: rake
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
prerelease: false
|
48
|
+
type: :development
|
49
|
+
name: rspec
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Set Partition
|
63
|
+
email:
|
64
|
+
- tejanium@yahoo.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- lib/set_partition.rb
|
75
|
+
- lib/set_partition/array.rb
|
76
|
+
- lib/set_partition/fixed_generator.rb
|
77
|
+
- lib/set_partition/generator.rb
|
78
|
+
- lib/set_partition/version.rb
|
79
|
+
- set_partition.gemspec
|
80
|
+
- spec/set_partition/array_spec.rb
|
81
|
+
- spec/set_partition/fixed_generator_spec.rb
|
82
|
+
- spec/set_partition/generator_spec.rb
|
83
|
+
homepage: http://github.com/tejanium/set_partition
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.8.25
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Ruby implementation of http://en.wikipedia.org/wiki/Partition_of_a_set based
|
108
|
+
on paper Efficient Generation of Set Partitions by Michael Orlov <orlovm@cs.bgu.ac.il>
|
109
|
+
test_files:
|
110
|
+
- spec/set_partition/array_spec.rb
|
111
|
+
- spec/set_partition/fixed_generator_spec.rb
|
112
|
+
- spec/set_partition/generator_spec.rb
|