Skip to content

Instantly share code, notes, and snippets.

Last active January 24, 2023 22:18
What would you like to do?
Compute coefficients for FA Cup probability trees. See
Compute coefficients for FA Cup probability trees.
from typing import List
from dataclasses import dataclass
class Fixture:
hosts: str
visitors: str
history: str
class Round:
fixtures: List[Fixture]
def __str__(self):
all_journeys = "".join([f.history for f in self.fixtures])
coefficients = [f"{all_journeys.count(c)}{c}" for c in "hax"]
return "(" + " + ".join([c for c in coefficients]) + f") / {len(self.fixtures)}"
rounds = [Round(fixtures=[Fixture(hosts="h", visitors="a", history="h")])]
for r in range(0, 5):
new_round = Round(fixtures=[])
prev_round = rounds[r]
for f in prev_round.fixtures:
new_round.fixtures.append(Fixture(f.hosts, "x", f.history + f.hosts))
new_round.fixtures.append(Fixture("x", f.hosts, f.history + "x"))
new_round.fixtures.append(Fixture(f.visitors, "x", f.history + f.visitors))
new_round.fixtures.append(Fixture("x", f.visitors, f.history + "x"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment