combinatorics 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +5 -5
- data/ChangeLog.md +11 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +1 -1
- data/README.md +144 -107
- data/Rakefile +6 -32
- data/combinatorics.gemspec +2 -4
- data/gemspec.yml +8 -4
- data/lib/combinatorics/cartesian_product/cardinality.rb +2 -0
- data/lib/combinatorics/cartesian_product/extensions/array.rb +3 -1
- data/lib/combinatorics/cartesian_product/extensions/set.rb +3 -1
- data/lib/combinatorics/cartesian_product/extensions.rb +4 -2
- data/lib/combinatorics/cartesian_product/mixin.rb +3 -1
- data/lib/combinatorics/cartesian_product.rb +5 -3
- data/lib/combinatorics/choose/cardinality.rb +4 -2
- data/lib/combinatorics/choose/extensions/array.rb +3 -1
- data/lib/combinatorics/choose/extensions/set.rb +4 -1
- data/lib/combinatorics/choose/extensions.rb +4 -2
- data/lib/combinatorics/choose/mixin.rb +2 -0
- data/lib/combinatorics/choose.rb +5 -3
- data/lib/combinatorics/derange/cardinality.rb +3 -1
- data/lib/combinatorics/derange/extensions/array.rb +3 -1
- data/lib/combinatorics/derange/extensions.rb +3 -1
- data/lib/combinatorics/derange/mixin.rb +2 -0
- data/lib/combinatorics/derange.rb +5 -3
- data/lib/combinatorics/enumerator.rb +2 -0
- data/lib/combinatorics/extensions/math.rb +2 -0
- data/lib/combinatorics/extensions/range.rb +2 -0
- data/lib/combinatorics/extensions.rb +3 -1
- data/lib/combinatorics/generator.rb +3 -1
- data/lib/combinatorics/list_comprehension.rb +3 -1
- data/lib/combinatorics/permute/cardinality.rb +3 -1
- data/lib/combinatorics/permute/extensions/array.rb +3 -1
- data/lib/combinatorics/permute/extensions/set.rb +3 -1
- data/lib/combinatorics/permute/extensions.rb +4 -2
- data/lib/combinatorics/permute/mixin.rb +2 -0
- data/lib/combinatorics/permute.rb +5 -3
- data/lib/combinatorics/power_set/cardinality.rb +3 -1
- data/lib/combinatorics/power_set/extensions/array.rb +3 -1
- data/lib/combinatorics/power_set/extensions/set.rb +3 -1
- data/lib/combinatorics/power_set/extensions.rb +4 -2
- data/lib/combinatorics/power_set/mixin.rb +2 -0
- data/lib/combinatorics/power_set.rb +5 -3
- data/lib/combinatorics/version.rb +3 -1
- data/lib/combinatorics.rb +12 -10
- data/spec/cartesian_product/cardinality_spec.rb +14 -16
- data/spec/cartesian_product/mixin_examples.rb +14 -14
- data/spec/choose/cardinality_spec.rb +32 -34
- data/spec/choose/mixin_examples.rb +6 -6
- data/spec/combinatorics_spec.rb +1 -1
- data/spec/derange/cardinality_spec.rb +1 -3
- data/spec/derange/mixin_examples.rb +6 -6
- data/spec/enumerator_spec.rb +1 -1
- data/spec/extensions/math_spec.rb +19 -19
- data/spec/extensions/range_spec.rb +12 -12
- data/spec/generator_spec.rb +1 -1
- data/spec/list_comprehension_spec.rb +10 -10
- data/spec/permute/cardinality_spec.rb +29 -31
- data/spec/permute/mixin_examples.rb +5 -5
- data/spec/power_set/cardinality_spec.rb +1 -3
- data/spec/power_set/mixin_examples.rb +4 -4
- data/spec/spec_helper.rb +2 -5
- metadata +26 -58
- data/.gemtest +0 -0
@@ -12,89 +12,89 @@ describe Math do
|
|
12
12
|
|
13
13
|
describe "sigma" do
|
14
14
|
it "should return 6 for sigma(1..3)" do
|
15
|
-
subject.sigma(1..3).
|
15
|
+
expect(subject.sigma(1..3)).to eq(6)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return 60 for sigma(3..5)" do
|
19
|
-
subject.sigma(3..5).
|
19
|
+
expect(subject.sigma(3..5)).to eq(12)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should take an optional block argument" do
|
23
23
|
result = subject.sigma(1..5) { |i| i * 2 }
|
24
24
|
|
25
|
-
result.
|
25
|
+
expect(result).to eq((1 * 2) + (2 * 2) + (3 * 2) + (4 * 2) + (5 * 2))
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "pi" do
|
30
30
|
it "should return 24 for pi(1..4)" do
|
31
|
-
subject.pi(1..4).
|
31
|
+
expect(subject.pi(1..4)).to eq(24)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return 30 for pi(5..6)" do
|
35
|
-
subject.pi(5..6).
|
35
|
+
expect(subject.pi(5..6)).to eq(30)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should take an optional block argument" do
|
39
39
|
result = subject.pi(1..3) { |i| i * 2 }
|
40
40
|
|
41
|
-
result.
|
41
|
+
expect(result).to eq((1 * 2) * (2 * 2) * (3 * 2))
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "factorial" do
|
46
46
|
it "should return 1 for factorial(0)" do
|
47
|
-
subject.factorial(0).
|
47
|
+
expect(subject.factorial(0)).to eq(1)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should return 1 for factorial(1)" do
|
51
|
-
subject.factorial(1).
|
51
|
+
expect(subject.factorial(1)).to eq(1)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should return 2 for factorial(2)" do
|
55
|
-
subject.factorial(2).
|
55
|
+
expect(subject.factorial(2)).to eq(2)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should return 6 for factorial(3)" do
|
59
|
-
subject.factorial(3).
|
59
|
+
expect(subject.factorial(3)).to eq(6)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should return 3628800 for factorial(10)" do
|
63
|
-
subject.factorial(10).
|
63
|
+
expect(subject.factorial(10)).to eq(3628800)
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should raise RangeError for factorial(-1)" do
|
67
|
-
|
67
|
+
expect { subject.factorial(-1) }.to raise_error(RangeError)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe "subfactorial" do
|
72
72
|
it "should return 1 for subfactorial(0)" do
|
73
|
-
subject.subfactorial(0).
|
73
|
+
expect(subject.subfactorial(0)).to eq(1)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should return 0 for subfactorial(1)" do
|
77
|
-
subject.subfactorial(1).
|
77
|
+
expect(subject.subfactorial(1)).to eq(0)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should return 1 for subfactorial(2)" do
|
81
|
-
subject.subfactorial(2).
|
81
|
+
expect(subject.subfactorial(2)).to eq(1)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should return 2 for subfactorial(3)" do
|
85
|
-
subject.subfactorial(3).
|
85
|
+
expect(subject.subfactorial(3)).to eq(2)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should return 9 for subfactorial(4)" do
|
89
|
-
subject.subfactorial(4).
|
89
|
+
expect(subject.subfactorial(4)).to eq(9)
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should return 44 for subfactorial(5)" do
|
93
|
-
subject.subfactorial(5).
|
93
|
+
expect(subject.subfactorial(5)).to eq(44)
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should raise RangeError for subfactorial(-1)" do
|
97
|
-
|
97
|
+
expect { subject.subfactorial(-1) }.to raise_error(RangeError)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -4,11 +4,11 @@ require 'combinatorics/extensions/range'
|
|
4
4
|
describe Range do
|
5
5
|
describe "&" do
|
6
6
|
it "should pick the maximum beginning value" do
|
7
|
-
((100..200) & (150..200)).first.
|
7
|
+
expect(((100..200) & (150..200)).first).to eq(150)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should pick the minimum ending value" do
|
11
|
-
((100..150) & (100..200)).last.
|
11
|
+
expect(((100..150) & (100..200)).last).to eq(150)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -16,28 +16,28 @@ describe Range do
|
|
16
16
|
subject { 1..10 }
|
17
17
|
|
18
18
|
it "should iterate over every beginning value" do
|
19
|
-
subject.upto(5..10).to_a.
|
19
|
+
expect(subject.upto(5..10).to_a).to eq([
|
20
20
|
(1..10),
|
21
21
|
(2..10),
|
22
22
|
(3..10),
|
23
23
|
(4..10),
|
24
24
|
(5..10)
|
25
|
-
]
|
25
|
+
])
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should iterate over every ending value" do
|
29
|
-
subject.upto(1..15).to_a.
|
29
|
+
expect(subject.upto(1..15).to_a).to eq([
|
30
30
|
(1..10),
|
31
31
|
(1..11),
|
32
32
|
(1..12),
|
33
33
|
(1..13),
|
34
34
|
(1..14),
|
35
35
|
(1..15)
|
36
|
-
]
|
36
|
+
])
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should not iterate up to lower bounding ranges" do
|
40
|
-
subject.upto(0..5).to_a.
|
40
|
+
expect(subject.upto(0..5).to_a).to be_empty
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,28 +45,28 @@ describe Range do
|
|
45
45
|
subject { 5..15 }
|
46
46
|
|
47
47
|
it "should iterate over every beginning value" do
|
48
|
-
subject.downto(1..15).to_a.
|
48
|
+
expect(subject.downto(1..15).to_a).to eq([
|
49
49
|
(5..15),
|
50
50
|
(4..15),
|
51
51
|
(3..15),
|
52
52
|
(2..15),
|
53
53
|
(1..15)
|
54
|
-
]
|
54
|
+
])
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should iterate over every ending value" do
|
58
|
-
subject.downto(5..10).to_a.
|
58
|
+
expect(subject.downto(5..10).to_a).to eq([
|
59
59
|
(5..15),
|
60
60
|
(5..14),
|
61
61
|
(5..13),
|
62
62
|
(5..12),
|
63
63
|
(5..11),
|
64
64
|
(5..10)
|
65
|
-
]
|
65
|
+
])
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should not iterate down to upward bounding ranges" do
|
69
|
-
subject.downto(10..20).to_a.
|
69
|
+
expect(subject.downto(10..20).to_a).to be_empty
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
data/spec/generator_spec.rb
CHANGED
@@ -6,46 +6,46 @@ describe "Array#comprehension" do
|
|
6
6
|
it "should return an Enumerator object if no block is given" do
|
7
7
|
a = [1..5]
|
8
8
|
|
9
|
-
a.comprehension.
|
9
|
+
expect(a.comprehension).not_to be_kind_of(Array)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should yield iterations to the given block" do
|
13
13
|
range = (1..5)
|
14
14
|
a = [range]
|
15
15
|
|
16
|
-
a.comprehension.to_a.
|
16
|
+
expect(a.comprehension.to_a).to eq([[1],[2],[3],[4],[5]])
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should do nothing an Array of all non-enumerable objects" do
|
20
20
|
a = [1,2,3]
|
21
21
|
|
22
|
-
a.comprehension.to_a.
|
22
|
+
expect(a.comprehension.to_a).to eq([a])
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should pass through an empty Array" do
|
26
26
|
a = []
|
27
27
|
|
28
|
-
a.comprehension.to_a.
|
28
|
+
expect(a.comprehension.to_a).to eq([a])
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should iterate over the values within an enumerable value" do
|
32
32
|
range = (1..5)
|
33
33
|
a = [range]
|
34
34
|
|
35
|
-
a.comprehension.to_a.
|
35
|
+
expect(a.comprehension.to_a).to eq([[1],[2],[3],[4],[5]])
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should iterate over repeating values" do
|
39
39
|
range = [1,2,3,1,2,4]
|
40
40
|
a = [range]
|
41
41
|
|
42
|
-
a.comprehension.to_a.
|
42
|
+
expect(a.comprehension.to_a).to eq([[1],[2],[3],[1],[2],[4]])
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should iterate over values from a generator" do
|
46
46
|
a = [Combinatorics::Generator.new { |g| 5.times { |i| g.yield i } }]
|
47
47
|
|
48
|
-
a.comprehension.to_a.
|
48
|
+
expect(a.comprehension.to_a).to eq([[0],[1],[2],[3],[4]])
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should iterate over values from a non-repeating generator" do
|
@@ -58,16 +58,16 @@ describe "Array#comprehension" do
|
|
58
58
|
}
|
59
59
|
]
|
60
60
|
|
61
|
-
a.comprehension.to_a.
|
61
|
+
expect(a.comprehension.to_a).to eq([
|
62
62
|
[1,0],[1,1],[1,2],[1,3],[1,4],
|
63
63
|
[2,0],[2,2],[2,4],[2,6],[2,8]
|
64
|
-
]
|
64
|
+
])
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should ignore non-enumerable values" do
|
68
68
|
range = (1..5)
|
69
69
|
a = [1,range]
|
70
70
|
|
71
|
-
a.comprehension.to_a.
|
71
|
+
expect(a.comprehension.to_a).to eq([[1,1],[1,2],[1,3],[1,4],[1,5]])
|
72
72
|
end
|
73
73
|
end
|
@@ -1,122 +1,120 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'combinatorics/permute'
|
3
3
|
|
4
|
-
describe Permute do
|
5
|
-
subject { Permute }
|
6
|
-
|
4
|
+
describe Combinatorics::Permute do
|
7
5
|
describe "cardinality" do
|
8
6
|
it "should raise RangeError if n is negative without passing r" do
|
9
|
-
|
7
|
+
expect { subject.cardinality(-1) }.to raise_error(RangeError)
|
10
8
|
end
|
11
9
|
|
12
10
|
it "should raise RangeError if n is negative when r is provided" do
|
13
|
-
|
11
|
+
expect { subject.cardinality(-1, 1) }.to raise_error(RangeError)
|
14
12
|
end
|
15
13
|
|
16
14
|
it "should raise RangeError if r is negative" do
|
17
|
-
|
15
|
+
expect { subject.cardinality(1, -1) }.to raise_error(RangeError)
|
18
16
|
end
|
19
17
|
|
20
18
|
it "should raise RangeError if r is greater than n" do
|
21
|
-
|
19
|
+
expect { subject.cardinality(2, 3) }.to raise_error(RangeError)
|
22
20
|
end
|
23
21
|
|
24
22
|
it "should return 1 for subject.cardinality(0)" do
|
25
|
-
subject.cardinality(0).
|
23
|
+
expect(subject.cardinality(0)).to eq(1)
|
26
24
|
end
|
27
25
|
|
28
26
|
it "should return 1 for subject.cardinality(1)" do
|
29
|
-
subject.cardinality(1).
|
27
|
+
expect(subject.cardinality(1)).to eq(1)
|
30
28
|
end
|
31
29
|
|
32
30
|
it "should return 2 for subject.cardinality(2)" do
|
33
|
-
subject.cardinality(2).
|
31
|
+
expect(subject.cardinality(2)).to eq(2)
|
34
32
|
end
|
35
33
|
|
36
34
|
it "should return 6 for subject.cardinality(3)" do
|
37
|
-
subject.cardinality(3).
|
35
|
+
expect(subject.cardinality(3)).to eq(6)
|
38
36
|
end
|
39
37
|
|
40
38
|
it "should return 24 for subject.cardinality(4)" do
|
41
|
-
subject.cardinality(4).
|
39
|
+
expect(subject.cardinality(4)).to eq(24)
|
42
40
|
end
|
43
41
|
|
44
42
|
it "should return 0 for subject.cardinality(1, 0)" do
|
45
|
-
subject.cardinality(1, 0).
|
43
|
+
expect(subject.cardinality(1, 0)).to eq(0)
|
46
44
|
end
|
47
45
|
|
48
46
|
it "should return 1 for subject.cardinality(1, 1)" do
|
49
|
-
subject.cardinality(1, 1).
|
47
|
+
expect(subject.cardinality(1, 1)).to eq(1)
|
50
48
|
end
|
51
49
|
|
52
50
|
it "should return 2 for subject.cardinality(2, 1)" do
|
53
|
-
subject.cardinality(2, 1).
|
51
|
+
expect(subject.cardinality(2, 1)).to eq(2)
|
54
52
|
end
|
55
53
|
|
56
54
|
it "should return 1 for subject.cardinality(2, 2)" do
|
57
|
-
subject.cardinality(2, 2).
|
55
|
+
expect(subject.cardinality(2, 2)).to eq(2)
|
58
56
|
end
|
59
57
|
|
60
58
|
it "should return 3 for subject.cardinality(3, 1)" do
|
61
|
-
subject.cardinality(3, 1).
|
59
|
+
expect(subject.cardinality(3, 1)).to eq(3)
|
62
60
|
end
|
63
61
|
|
64
62
|
it "should return 3 for subject.cardinality(3, 2)" do
|
65
|
-
subject.cardinality(3, 2).
|
63
|
+
expect(subject.cardinality(3, 2)).to eq(6)
|
66
64
|
end
|
67
65
|
|
68
66
|
it "should return 1 for subject.cardinality(3, 3)" do
|
69
|
-
subject.cardinality(3, 3).
|
67
|
+
expect(subject.cardinality(3, 3)).to eq(6)
|
70
68
|
end
|
71
69
|
|
72
70
|
it "should return 4 for subject.cardinality(4, 1)" do
|
73
|
-
subject.cardinality(4, 1).
|
71
|
+
expect(subject.cardinality(4, 1)).to eq(4)
|
74
72
|
end
|
75
73
|
|
76
74
|
it "should return 12 for subject.cardinality(4, 2)" do
|
77
|
-
subject.cardinality(4, 2).
|
75
|
+
expect(subject.cardinality(4, 2)).to eq(12)
|
78
76
|
end
|
79
77
|
|
80
78
|
it "should return 24 for subject.cardinality(4, 3)" do
|
81
|
-
subject.cardinality(4, 3).
|
79
|
+
expect(subject.cardinality(4, 3)).to eq(24)
|
82
80
|
end
|
83
81
|
|
84
82
|
it "should return 1 for subject.cardinality(4, 4)" do
|
85
|
-
subject.cardinality(4, 4).
|
83
|
+
expect(subject.cardinality(4, 4)).to eq(24)
|
86
84
|
end
|
87
85
|
|
88
86
|
it "should return 360 for subject.cardinality(6, 4)" do
|
89
|
-
subject.cardinality(6, 4).
|
87
|
+
expect(subject.cardinality(6, 4)).to eq(360)
|
90
88
|
end
|
91
89
|
|
92
90
|
it "should return 3628800 for subject.cardinality(10)" do
|
93
|
-
subject.cardinality(10).
|
91
|
+
expect(subject.cardinality(10)).to eq(3628800)
|
94
92
|
end
|
95
93
|
end
|
96
94
|
|
97
95
|
describe "cardinality_all" do
|
98
96
|
it "should return [] for cardinality_all(0)" do
|
99
|
-
subject.cardinality_all(0).
|
97
|
+
expect(subject.cardinality_all(0)).to be_empty
|
100
98
|
end
|
101
99
|
|
102
100
|
it "should return [1] for cardinality_all(1)" do
|
103
|
-
subject.cardinality_all(1).
|
101
|
+
expect(subject.cardinality_all(1)).to eq([1])
|
104
102
|
end
|
105
103
|
|
106
104
|
it "should return [2, 1] for cardinality_all(2)" do
|
107
|
-
subject.cardinality_all(2).
|
105
|
+
expect(subject.cardinality_all(2)).to eq([2, 2])
|
108
106
|
end
|
109
107
|
|
110
108
|
it "should return [3, 6, 1] for cardinality_all(3)" do
|
111
|
-
subject.cardinality_all(3).
|
109
|
+
expect(subject.cardinality_all(3)).to eq([3, 6, 6])
|
112
110
|
end
|
113
111
|
|
114
112
|
it "should return [4, 12, 24, 1] for cardinality_all(4)" do
|
115
|
-
subject.cardinality_all(4).
|
113
|
+
expect(subject.cardinality_all(4)).to eq([4, 12, 24, 24])
|
116
114
|
end
|
117
115
|
|
118
116
|
it "should raise RangeError for cardinality_all(-1)" do
|
119
|
-
|
117
|
+
expect { subject.cardinality_all(-1) }.to raise_error(RangeError)
|
120
118
|
end
|
121
119
|
|
122
120
|
it "should wrap cardinality with Permute.N" do
|
@@ -8,35 +8,35 @@ shared_examples_for "Permute::Mixin" do
|
|
8
8
|
set = subject[]
|
9
9
|
results = set.permute(0).to_a
|
10
10
|
|
11
|
-
results.
|
11
|
+
expect(results).to eq([[]])
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return [[]] for [1].permute(0).to_a" do
|
15
15
|
set = subject[1]
|
16
16
|
results = set.permute(0).to_a
|
17
17
|
|
18
|
-
results.
|
18
|
+
expect(results).to eq([[]])
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return [[1]] for [1].permute(1).to_a" do
|
22
22
|
set = subject[1]
|
23
23
|
results = set.permute(1).to_a
|
24
24
|
|
25
|
-
results.
|
25
|
+
expect(results).to eq([[1]])
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return [[1], [2]] for [1, 2].permute(1).to_a" do
|
29
29
|
set = subject[1, 2]
|
30
30
|
results = set.permute(1).to_a
|
31
31
|
|
32
|
-
results.
|
32
|
+
expect(results).to match_array([[1], [2]])
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return [[1, 2]] for [1, 2].permute(2).to_a" do
|
36
36
|
set = subject[1, 2]
|
37
37
|
results = set.permute(2).to_a
|
38
38
|
|
39
|
-
results.
|
39
|
+
expect(results).to match_array([[1, 2], [2, 1]])
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -8,13 +8,13 @@ shared_examples_for "PowerSet::Mixin" do
|
|
8
8
|
it "the powerset of an empty Set should only contain the empty Set" do
|
9
9
|
set = subject[]
|
10
10
|
|
11
|
-
set.powerset.to_a.
|
11
|
+
expect(set.powerset.to_a).to eq([empty_set])
|
12
12
|
end
|
13
13
|
|
14
14
|
it "the powerset of a single Set should contain that Set" do
|
15
15
|
set = subject[1]
|
16
16
|
|
17
|
-
set.powerset.to_a.
|
17
|
+
expect(set.powerset.to_a).to eq([empty_set, Set[*set]])
|
18
18
|
end
|
19
19
|
|
20
20
|
it "the powerset of a Set should all be subsets" do
|
@@ -23,12 +23,12 @@ shared_examples_for "PowerSet::Mixin" do
|
|
23
23
|
|
24
24
|
set.powerset { |subset| superset += subset }
|
25
25
|
|
26
|
-
superset.
|
26
|
+
expect(superset).to eq(Set[*set])
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should alias powerset to power_set" do
|
30
30
|
set = subject[1]
|
31
31
|
|
32
|
-
set.
|
32
|
+
expect(set).to respond_to(:power_set)
|
33
33
|
end
|
34
34
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,65 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: combinatorics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Postmodern
|
9
8
|
- Duper
|
10
|
-
autorequire:
|
9
|
+
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
15
|
+
name: bundler
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- - ~>
|
18
|
+
- - "~>"
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0
|
20
|
+
version: '2.0'
|
23
21
|
type: :development
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- - ~>
|
25
|
+
- - "~>"
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '0
|
31
|
-
- !ruby/object:Gem::Dependency
|
32
|
-
name: rspec
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
|
-
requirements:
|
36
|
-
- - ~>
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '2.4'
|
39
|
-
type: :development
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
|
-
requirements:
|
44
|
-
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '2.4'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: yard
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.7'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ~>
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0.7'
|
27
|
+
version: '2.0'
|
63
28
|
description: A collection of modules and methods for performing Combinatoric calculations.
|
64
29
|
email:
|
65
30
|
- postmodern.mod3@gmail.com
|
@@ -72,13 +37,14 @@ extra_rdoc_files:
|
|
72
37
|
- LICENSE.txt
|
73
38
|
- README.md
|
74
39
|
files:
|
75
|
-
- .document
|
76
|
-
- .
|
77
|
-
- .gitignore
|
78
|
-
- .rspec
|
79
|
-
- .yardopts
|
40
|
+
- ".document"
|
41
|
+
- ".github/workflows/ruby.yml"
|
42
|
+
- ".gitignore"
|
43
|
+
- ".rspec"
|
44
|
+
- ".yardopts"
|
80
45
|
- Benchmarks.md
|
81
46
|
- ChangeLog.md
|
47
|
+
- Gemfile
|
82
48
|
- LICENSE.txt
|
83
49
|
- README.md
|
84
50
|
- Rakefile
|
@@ -157,26 +123,28 @@ files:
|
|
157
123
|
homepage: https://github.com/postmodern/combinatorics#readme
|
158
124
|
licenses:
|
159
125
|
- MIT
|
160
|
-
|
126
|
+
metadata:
|
127
|
+
documentation_uri: https://rubydoc.info/gems/combinatorics
|
128
|
+
source_code_uri: https://github.com/postmodern/combinatorics.rb
|
129
|
+
bug_tracker_uri: https://github.com/postmodern/combinatorics.rb/issues
|
130
|
+
changelog_uri: https://github.com/postmodern/combinatorics.rb/blob/master/ChangeLog.md
|
131
|
+
post_install_message:
|
161
132
|
rdoc_options: []
|
162
133
|
require_paths:
|
163
134
|
- lib
|
164
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
-
none: false
|
166
136
|
requirements:
|
167
|
-
- -
|
137
|
+
- - ">="
|
168
138
|
- !ruby/object:Gem::Version
|
169
|
-
version:
|
139
|
+
version: 2.0.0
|
170
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
-
none: false
|
172
141
|
requirements:
|
173
|
-
- -
|
142
|
+
- - ">="
|
174
143
|
- !ruby/object:Gem::Version
|
175
144
|
version: '0'
|
176
145
|
requirements: []
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
specification_version: 3
|
146
|
+
rubygems_version: 3.4.10
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
181
149
|
summary: Bringing (more) Combinatorics to Ruby
|
182
150
|
test_files: []
|
data/.gemtest
DELETED
File without changes
|