Skip to content

Instantly share code, notes, and snippets.

View kruszczynski's full-sized avatar
🎛️
Softer Developer

Bartek Kruszczynski kruszczynski

🎛️
Softer Developer
View GitHub Profile
@kruszczynski
kruszczynski / tennis-02.md
Last active August 25, 2026 11:36
Tennis tournament exercise, part 02

Stage 2

matches = [["Alice", "Bob"], ["Charlie", "David"], ["Alice", "Charlie"], ["Bob", "David"]]
@kruszczynski
kruszczynski / tennis-03.md
Last active August 25, 2026 11:36
Tennis tournament exercise, part 03

Stage 3

matches = [["Alice", "Bob"], ["Yuki", "Zoe"]]
@kruszczynski
kruszczynski / tennis-04.md
Created August 25, 2026 09:30
Tennis tournament exercise, part 04

Stage 4: hostile inputs

The match list arrives as JSON over an API from a third party. You do not control what they send.

[]                                        # no matches at all
[["Alice", "Alice"]]                      # a player against themselves
[["Alice", "Bob"], ["Alice", "Bob"]]      # the same match twice
[["Alice"]] # arity is not guaranteed
@kruszczynski
kruszczynski / tennis-05.md
Created August 25, 2026 09:30
Tennis tournament exercise, part 05

Stage 5: a full season

The rights holders come back with the real fixture list.

matches = [[f"player{i}", f"player{i+1}"] for i in range(50_000)]

Run it.

@kruszczynski
kruszczynski / tennis-08.md
Created August 25, 2026 09:30
Tennis tournament exercise, part 08

Stage 8: the rights holders return

Reason about these out loud. No implementation needed.

  1. Three teams. They now want players split across Team A, B and C, same rule: no player faces a teammate. How does your approach change?

  2. Best effort. The fixture list has no valid two-team split, but they refuse to drop matches. Instead they want the assignment that honours as many of the requested matches as possible. What is this problem?