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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 602722f9a01df5d8ac2c4d6fa8891ba4af1c24fb7420411af5f7b7e9a1914858
4
- data.tar.gz: f6bcabe982701d5a4a2dece4b9b4368d1c5dba3d1e1e1b79ecc1fd83295ec13d
3
+ metadata.gz: 828e686fac3eaaf42dd31aa4dd1f1f6e12b218fa0a36d79b60a10bfe15a5ebc5
4
+ data.tar.gz: 0d62e40b862597cfc0cc96e8d38409ccc677b64bf96c0dd97912c3fc96dd1f75
5
5
  SHA512:
6
- metadata.gz: 5fc2438012012087bb18d08236be7f04fb76bb06a644947833168d0c75fd7effe34ed1abfcab50756c8a631000dd5b3b3000332af6783dc7b5b97f1d9eb41b87
7
- data.tar.gz: c46981d03da742a33febcc0c1dfaa8ad174cf2bdde1782c28d3a21cac340e82709d9b791b74fbe04c2099c079be8f446e37c073c8752326aef3d5d441e3525da
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.0`, the tournament rotation has been reversed, which brings **stability** on first day pairs for a growing number for participants.
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
 
@@ -1,3 +1,3 @@
1
1
  module RoundRobinTournament
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -3,12 +3,16 @@ require 'round_robin_tournament/version'
3
3
  module RoundRobinTournament
4
4
 
5
5
  def self.schedule(array)
6
- array.push nil if array.size.odd?
6
+ array.push(nil) if array.size.odd?
7
7
  n = array.size
8
- pivot = array.shift
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
- [[array.first, pivot]] + (1...(n / 2)).map { |j| [array[j], array[n - 1 - j]] }
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', '~> 1.7'
22
- spec.add_development_dependency 'rake', '~> 10.0'
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
- 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'])
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.0
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: 2020-12-05 00:00:00.000000000 Z
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: '1.7'
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: '1.7'
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: '10.0'
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: '10.0'
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.0.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: