Case 108
Tournament bracket
tournament_bracket.eml runs a single-elimination tournament: pair up adjacent teams, the stronger rating advances, repeat on the surviving half until one team is left. Eight teams take exactly three rounds.
ok: true — round-trip fixpoint reached (python1 == python2)updated 2026-07-26
EML
eml# Self-authored for the EML case corpus (no external origin). A
# single-elimination tournament: pair up adjacent teams, the stronger
# rating advances, repeat on the surviving half until one team is left.
# Each round halves the field, so 8 teams take exactly 3 rounds.
#
# Outcomes are decided by rating rather than chance because the corpus's
# execution-truth gate compares interpreter output against a real Python
# run byte for byte — anything random would differ between the two and the
# case could never pass. This is the same reason
# examples/dice-roll-tally/ and examples/rock-paper-scissors-simulator/
# use fixed scripted inputs rather than a random source.
#
# The starting order is arranged to make one point visible: seeding is not
# fairness. The two highest-rated teams (Tigers 95, Wolves 91) sit in the
# same half of the bracket, so they meet in the SEMI-FINAL — the
# second-strongest team is eliminated one round early, and a weaker side
# reaches the final purely by starting in the emptier half.
def play_round(teams, ratings):
winners^+[]
0 => i
while i < len(teams):
teams[i] => home
teams[i + 1] => away
if ratings[home] >= ratings[away]:
home => winner
else:
away => winner
winners + [winner] => winners
" " + home + " (" + str(ratings[home]) + ") vs " + away + " (" + str(ratings[away]) + ") -> " + winner => line
line^0
i + 2 => i
return winners
teams^+["Falcons", "Tigers", "Wolves", "Bears", "Eagles", "Sharks", "Lions", "Hawks"]
ratings^+{"Falcons": 82, "Sharks": 74, "Wolves": 91, "Bears": 88, "Eagles": 69, "Tigers": 95, "Lions": 77, "Hawks": 84}
1 => round_number
while len(teams) > 1:
"Round " + str(round_number) + " (" + str(len(teams)) + " teams):" => header
header^0
play_round(teams, ratings) => teams
round_number + 1 => round_number
"" => blank
blank^0
"Champion: " + teams[0] + " (rating " + str(ratings[teams[0]]) + ")" => champion_line
champion_line^0Python (deterministic transpilation)
pythondef play_round(teams, ratings):
winners = []
i = 0
while i < len(teams):
home = teams[i]
away = teams[i + 1]
if ratings[home] >= ratings[away]:
winner = home
else:
winner = away
winners = winners + [winner]
line = " " + home + " (" + str(ratings[home]) + ") vs " + away + " (" + str(ratings[away]) + ") -> " + winner
print(line)
i = i + 2
return winners
teams = ["Falcons", "Tigers", "Wolves", "Bears", "Eagles", "Sharks", "Lions", "Hawks"]
ratings = {"Falcons": 82, "Sharks": 74, "Wolves": 91, "Bears": 88, "Eagles": 69, "Tigers": 95, "Lions": 77, "Hawks": 84}
round_number = 1
while len(teams) > 1:
header = "Round " + str(round_number) + " (" + str(len(teams)) + " teams):"
print(header)
teams = play_round(teams, ratings)
round_number = round_number + 1
blank = ""
print(blank)
champion_line = "Champion: " + teams[0] + " (rating " + str(ratings[teams[0]]) + ")"
print(champion_line)stdout (executed)
textRound 1 (8 teams):
Falcons (82) vs Tigers (95) -> Tigers
Wolves (91) vs Bears (88) -> Wolves
Eagles (69) vs Sharks (74) -> Sharks
Lions (77) vs Hawks (84) -> Hawks
Round 2 (4 teams):
Tigers (95) vs Wolves (91) -> Tigers
Sharks (74) vs Hawks (84) -> Hawks
Round 3 (2 teams):
Tigers (95) vs Hawks (84) -> Tigers
Champion: Tigers (rating 95)Trace event types
eml:run:starteml:defeml:assigneml:outputeml:calleml:returneml:run:done