Skip to content

Instantly share code, notes, and snippets.

@aleksey-rezvov
Last active April 17, 2024 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save aleksey-rezvov/82c6ac7f1cc18bc97ffc59021b030a43 to your computer and use it in GitHub Desktop.
Save aleksey-rezvov/82c6ac7f1cc18bc97ffc59021b030a43 to your computer and use it in GitHub Desktop.
const emptyScoreStamp = {
offset: 0,
score: {
home: 0,
away: 0
}
};
export const scoreStamps = Array(50000).fill(emptyScoreStamp).map(
((acc) => () => {
const scoreChanged = Math.random() > 0.9999;
const homeScoreChange = scoreChanged && Math.random() > 0.55 ? 1 : 0;
const awayScoreChange = scoreChanged && !homeScoreChange ? 1 : 0;
return {
offset: acc.offset += Math.floor(Math.random() * 3) + 1,
score: {
home: acc.score.home += homeScoreChange,
away: acc.score.away += awayScoreChange
}
};
}
)(emptyScoreStamp)
);
export const getScore = (offset: number) : {home: number, away: number} => {
// continue the function's implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment