round_robin_tournament 0.0.1 → 0.1.0
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.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/README.md +11 -1
- data/lib/round_robin_tournament.rb +1 -1
- data/lib/round_robin_tournament/version.rb +1 -1
- data/spec/round_robin_tournament_spec.rb +14 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 602722f9a01df5d8ac2c4d6fa8891ba4af1c24fb7420411af5f7b7e9a1914858
|
4
|
+
data.tar.gz: f6bcabe982701d5a4a2dece4b9b4368d1c5dba3d1e1e1b79ecc1fd83295ec13d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fc2438012012087bb18d08236be7f04fb76bb06a644947833168d0c75fd7effe34ed1abfcab50756c8a631000dd5b3b3000332af6783dc7b5b97f1d9eb41b87
|
7
|
+
data.tar.gz: c46981d03da742a33febcc0c1dfaa8ad174cf2bdde1782c28d3a21cac340e82709d9b791b74fbe04c2099c079be8f446e37c073c8752326aef3d5d441e3525da
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
[](https://travis-ci.org/ssaunier/round_robin_tournament)
|
2
|
+
[](http://rubygems.org/gems/round_robin_tournament)
|
2
3
|
|
3
4
|
# Round Robin Tournament
|
4
5
|
|
@@ -6,6 +7,10 @@ This little ruby gem implements the [Round Robin Tournament](http://en.wikipedia
|
|
6
7
|
"in which each contestant meets all other contestants in turn", or if you have a classroom
|
7
8
|
of students and want them to work in pairs, but with a different partner every day.
|
8
9
|
|
10
|
+
## Upgrade
|
11
|
+
|
12
|
+
If you upgrade from version `0.0.1` to `0.1.0`, the tournament rotation has been reversed, which brings **stability** on first day pairs for a growing number for participants.
|
13
|
+
|
9
14
|
## Installation
|
10
15
|
|
11
16
|
Add this line to your application's Gemfile:
|
@@ -67,4 +72,9 @@ end
|
|
67
72
|
# Day 3: (George, ), (OtherGuy, Ringo), (John, Paul)
|
68
73
|
# Day 4: (OtherGuy, ), (John, George), (Paul, Ringo)
|
69
74
|
# Day 5: (John, ), (Paul, OtherGuy), (Ringo, George)
|
70
|
-
```
|
75
|
+
```
|
76
|
+
|
77
|
+
## Credits
|
78
|
+
|
79
|
+
I'd like to thank [Pierre-Olivier Goffard](http://pierre-olivier.goffard.me/),
|
80
|
+
Joel Cohen and Florent Rovetta from the [*Institut de Mathématiques de Marseille*](http://iml.univ-mrs.fr/) who helped a lot!
|
@@ -5,7 +5,7 @@ module RoundRobinTournament
|
|
5
5
|
def self.schedule(array)
|
6
6
|
array.push nil if array.size.odd?
|
7
7
|
n = array.size
|
8
|
-
pivot = array.
|
8
|
+
pivot = array.shift
|
9
9
|
games = (n - 1).times.map do
|
10
10
|
array.rotate!
|
11
11
|
[[array.first, pivot]] + (1...(n / 2)).map { |j| [array[j], array[n - 1 - j]] }
|
@@ -20,6 +20,20 @@ describe RoundRobinTournament do
|
|
20
20
|
teams = RoundRobinTournament.schedule(students)
|
21
21
|
expect { check_schedule!(teams) }.not_to raise_error
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'is stable growing the number of participants by 1' do
|
25
|
+
day_four = RoundRobinTournament.schedule(%w[a b c d]).first
|
26
|
+
day_five = RoundRobinTournament.schedule(%w[a b c d e]).first
|
27
|
+
expect(day_five[0..1]).to eq(day_four)
|
28
|
+
expect(day_five.last).to eq(['e', nil])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'is stable growing the number of participants by 2' do
|
32
|
+
day_four = RoundRobinTournament.schedule(%w[a b c d]).first
|
33
|
+
day_six = RoundRobinTournament.schedule(%w[a b c d e f]).first
|
34
|
+
expect(day_six[0..1]).to eq(day_four)
|
35
|
+
expect(day_six.last).to eq(['e', 'f'])
|
36
|
+
end
|
23
37
|
end
|
24
38
|
|
25
39
|
def check_schedule!(schedule)
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Saunier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,8 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.4.2
|
93
|
+
rubygems_version: 3.0.3
|
95
94
|
signing_key:
|
96
95
|
specification_version: 4
|
97
96
|
summary: Round Robin Tournament schedule for competitions or classroom teams
|