round_robin_tournament 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +1 -1
- data/lib/round_robin_tournament/version.rb +1 -1
- data/lib/round_robin_tournament.rb +7 -3
- data/round_robin_tournament.gemspec +2 -2
- data/spec/round_robin_tournament_spec.rb +14 -12
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 828e686fac3eaaf42dd31aa4dd1f1f6e12b218fa0a36d79b60a10bfe15a5ebc5
|
4
|
+
data.tar.gz: 0d62e40b862597cfc0cc96e8d38409ccc677b64bf96c0dd97912c3fc96dd1f75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 190208b044f207d4f337f3597ad4828593b97c7f92a1e7cf971ca8a527004c731ad6ef795e2fd3149c4f39eb6e9d96ed9e1f677c1f7296e614bbb03945a645d5
|
7
|
+
data.tar.gz: 8d06ca814f2f375d948a1dbb08f31e0723e3841f58ee190eb8f3bc13908edbd0c0308193df176e34c1f4e9a7459a7f0150706bb6a5dfa6f3724d3628d3ddfea0
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ of students and want them to work in pairs, but with a different partner every d
|
|
9
9
|
|
10
10
|
## Upgrade
|
11
11
|
|
12
|
-
If you upgrade from version `0.0.1` to `0.1.
|
12
|
+
If you upgrade from version `0.0.1` to `0.1.2`, the tournament rotation has been reversed, which brings **stability** on first day pairs for a growing number for participants.
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
@@ -3,12 +3,16 @@ require 'round_robin_tournament/version'
|
|
3
3
|
module RoundRobinTournament
|
4
4
|
|
5
5
|
def self.schedule(array)
|
6
|
-
array.push
|
6
|
+
array.push(nil) if array.size.odd?
|
7
7
|
n = array.size
|
8
|
-
|
8
|
+
1.step(n / 2, 1).each do |i|
|
9
|
+
array.insert(n - i, array.delete_at(i))
|
10
|
+
end
|
11
|
+
pivot = array.pop
|
9
12
|
games = (n - 1).times.map do
|
13
|
+
day = [[array.first, pivot]] + (1...(n / 2)).map { |j| [array[j], array[n - 1 - j]] }
|
10
14
|
array.rotate!
|
11
|
-
|
15
|
+
day
|
12
16
|
end
|
13
17
|
array.push pivot unless pivot.nil?
|
14
18
|
games
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~>
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
21
|
+
spec.add_development_dependency 'bundler', '~> 2.4'
|
22
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
24
|
end
|
@@ -21,18 +21,20 @@ describe RoundRobinTournament do
|
|
21
21
|
expect { check_schedule!(teams) }.not_to raise_error
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
(2..20).to_a.each do |n|
|
25
|
+
it "is stable growing the number of participants from #{n} to #{n + 1}" do
|
26
|
+
day_one = RoundRobinTournament.schedule(("a".."z").to_a.take(n)).first
|
27
|
+
participants_day_two = ("a".."z").to_a.take(n + 1)
|
28
|
+
participants_day_two_last = participants_day_two.last
|
29
|
+
day_two = RoundRobinTournament.schedule(participants_day_two).first
|
30
|
+
|
31
|
+
if n.even?
|
32
|
+
day_two = day_two.reject { |pair| pair.compact.size != 2 }
|
33
|
+
else
|
34
|
+
day_one = day_one.map { |pair| pair.map { |participant| participant.nil? ? participants_day_two_last : participant } }
|
35
|
+
end
|
36
|
+
expect(day_two).to eq(day_one)
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: round_robin_tournament
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Saunier
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.4'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +61,7 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
|
+
- ".ruby-version"
|
64
65
|
- ".travis.yml"
|
65
66
|
- Gemfile
|
66
67
|
- LICENSE.txt
|
@@ -75,7 +76,7 @@ homepage: https://github.com/ssaunier/round_robin_tournament
|
|
75
76
|
licenses:
|
76
77
|
- MIT
|
77
78
|
metadata: {}
|
78
|
-
post_install_message:
|
79
|
+
post_install_message:
|
79
80
|
rdoc_options: []
|
80
81
|
require_paths:
|
81
82
|
- lib
|
@@ -90,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
- !ruby/object:Gem::Version
|
91
92
|
version: '0'
|
92
93
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
94
|
-
signing_key:
|
94
|
+
rubygems_version: 3.4.10
|
95
|
+
signing_key:
|
95
96
|
specification_version: 4
|
96
97
|
summary: Round Robin Tournament schedule for competitions or classroom teams
|
97
98
|
test_files:
|