Skip to content

Instantly share code, notes, and snippets.

@cacheflow
Last active August 8, 2019 19:17
Show Gist options
  • Save cacheflow/868c7f2187cdf2ded12187dea61fa086 to your computer and use it in GitHub Desktop.
Save cacheflow/868c7f2187cdf2ded12187dea61fa086 to your computer and use it in GitHub Desktop.
[
[
[a, b],
[c, d]
],
[
[a, d]
]
]
const players = [a, b, c, d]
const rounds = 4
(1..rounds).reduce((accumulated) => {
if (accumulated.length == rounds - 1) {
return accumulated
}
return [...accumulated, generateRound(discoverWinners(accumulated))]
}, [generateRound(players)])
// Pairings = Array<VS>
// ReadyPlayers = Array<Player>
// RoundList => ReadyPlayers
function discoverWinners (rounds) {
return rounds.last().map(battle)
}
// ReadyPlayers => Pairings
function generateRound (players) {
return ...
}
// VS = [Player, Player]
// VS => Winner
function battle(vs) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment