Compare commits
3 Commits
1fcca38576
...
4e6796dbc8
Author | SHA1 | Date | |
---|---|---|---|
4e6796dbc8 | |||
e3ce152496 | |||
4193cc4d6d |
@ -9,7 +9,7 @@ module Tables
|
|||||||
|
|
||||||
def each
|
def each
|
||||||
@initial_solution.tables.permutation(2) do |table_a, table_b|
|
@initial_solution.tables.permutation(2) do |table_a, table_b|
|
||||||
table_a.dup.each do |person|
|
table_a.each do |person|
|
||||||
original_discomfort_a = table_a.reset
|
original_discomfort_a = table_a.reset
|
||||||
original_discomfort_b = table_b.reset
|
original_discomfort_b = table_b.reset
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# Copyright (C) 2024 Manuel Bustillo
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
module Tables
|
module Tables
|
||||||
@ -14,37 +16,17 @@ module Tables
|
|||||||
context 'when there are two tables with two people each' do
|
context 'when there are two tables with two people each' do
|
||||||
let(:initial_solution) do
|
let(:initial_solution) do
|
||||||
Distribution.new(min_per_table: 2, max_per_table: 2).tap do |distribution|
|
Distribution.new(min_per_table: 2, max_per_table: 2).tap do |distribution|
|
||||||
distribution.tables << Set[:a, :b].to_table
|
distribution.tables << %i[a b].to_table
|
||||||
distribution.tables << Set[:c, :d].to_table
|
distribution.tables << %i[c d].to_table
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'yields all possible shifts between the tables' do
|
it 'yields all possible shifts between the tables' do
|
||||||
expect(shifts).to contain_exactly(
|
expect(shifts).to contain_exactly(
|
||||||
[Set[:b], Set[:c, :d, :a]],
|
[[:b], %i[c d a]],
|
||||||
[Set[:a], Set[:c, :d, :b]],
|
[[:a], %i[c d b]],
|
||||||
[Set[:b, :a, :d], Set[:c]],
|
[%i[b a d], [:c]],
|
||||||
[Set[:b, :a, :c], Set[:d]]
|
[%i[b a c], [:d]]
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when there are two tables with three people each' do
|
|
||||||
let(:initial_solution) do
|
|
||||||
Distribution.new(min_per_table: 3, max_per_table: 3).tap do |distribution|
|
|
||||||
distribution.tables << Set[:a, :b, :c].to_table
|
|
||||||
distribution.tables << Set[:d, :e, :f].to_table
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'yields all possible shifts between the tables' do
|
|
||||||
expect(shifts).to contain_exactly(
|
|
||||||
[Set[:b, :c], Set[:d, :e, :f, :a]],
|
|
||||||
[Set[:c, :a], Set[:d, :e, :f, :b]],
|
|
||||||
[Set[:a, :b], Set[:d, :e, :f, :c]],
|
|
||||||
[Set[:a, :b, :c, :d], Set[:e, :f]],
|
|
||||||
[Set[:a, :b, :c, :e], Set[:d, :f]],
|
|
||||||
[Set[:a, :b, :c, :f], Set[:d, :e]]
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user