# Room squares and Tournaments

A Room square is a variation on a Latin square. Room squares are named after Thomas Room, though there is an application to rooms as in compartments of a building that we’ll discuss below.

In a Latin square of size n you have to assign one of n symbols to each cell so that each symbol appears exactly once in each row and column. A Room square is sort of a Latin square with pairs.

Each cell of a Room square is either empty or contains an unordered pair of symbols. Each symbol appears exactly once in each row and column, and every possible pair of symbols appears in some cell.

The following graphic shows a 7 × 7 Room square with eight symbols, each represented by a different color. If you have trouble seeing some of the colors, take a look at the code below that made the image.

An n × n Room square corresponds to a Round Robin tournament schedule with n + 1 players. Each row represents a location (or room), and each column represents a round. Each player plays one game in each round, and each pair of players plays in exactly one location.

## Python code

Here’s the code I wrote to create the image above.

```    import matplotlib.pyplot as plt

colors = ["red", "orange", "yellow", "green", "blue", "black", "gray", "purple"]
up, dn = True, False

def draw_triangle(row, col, value, pos):
if pos == up:
x = [col, col, col+1]
y = [row, row+1, row+1]
else:
x = [col, col+1, col+1]
y = [row, row, row+1]
plt.fill(x, y, colors[value])

sq = [
(1, 3, 0, 4),
(1, 5, 3, 5),
(1, 6, 1, 2),
(1, 7, 7, 6),
(2, 2, 6, 3),
(2, 4, 2, 4),
(2, 5, 0, 1),
(2, 6, 7, 5),
(3, 1, 5, 2),
(3, 3, 1, 3),
(3, 4, 6, 0),
(3, 5, 7, 4),
(4, 2, 0, 2),
(4, 3, 5, 6),
(4, 4, 7, 3),
(4, 7, 4, 1),
(5, 1, 6, 1),
(5, 2, 4, 5),
(5, 3, 7, 2),
(5, 6, 3, 0),
(6, 1, 3, 4),
(6, 2, 7, 1),
(6, 5, 2, 6),
(6, 7, 5, 0),
(7, 1, 7, 0),
(7, 4, 1, 5),
(7, 6, 4, 6),
(7, 7, 2, 3)
]

for t in sq:
draw_triangle(t, t, t, up)
draw_triangle(t, t, t, dn)
plt.grid()

plt.gca().set_aspect("equal")
plt.show()
```

## 2 thoughts on “Room squares and Tournaments”

1. Kaleberg

Are these what they call Greco-Latin squares? The idea is that instead of colors, each cell is marked with a latin letter and a greek letter.