Skip to content

Instantly share code, notes, and snippets.

@Jeandcc
Created January 1, 2021 02:01
Show Gist options
  • Save Jeandcc/f689fa8ebe4fd8444097e1f852c1a2fb to your computer and use it in GitHub Desktop.
Save Jeandcc/f689fa8ebe4fd8444097e1f852c1a2fb to your computer and use it in GitHub Desktop.
const pickedNumbers = [17, 20, 22, 35, 41, 42];
const playedGames = [
[04, 06, 15, 27, 36, 45],
[08, 18, 23, 27, 51, 56],
[03, 26, 33, 34, 39, 44],
[09, 32, 37, 38, 41, 47],
[04, 21, 23, 49, 52, 56],
[01, 19, 36, 38, 51, 60],
[04, 15, 28, 29, 34, 39],
[16, 24, 39, 47, 52, 54],
[11, 12, 32, 41, 47, 53],
[17, 23, 28, 32, 43, 59],
[21, 26, 35, 41, 46, 48],
[01, 08, 31, 36, 45, 48],
[07, 11, 33, 38, 42, 50],
[05, 10, 14, 31, 46, 51],
[17, 19, 23, 33, 40, 50],
[12, 16, 29, 44, 48, 53],
[10, 17, 19, 25, 34, 47],
[03, 07, 22, 31, 42, 49],
[05, 14, 23, 35, 36, 60],
[08, 20, 30, 32, 51, 55],
[06, 08, 27, 28, 36, 59],
[02, 15, 17, 21, 33, 48],
[03, 19, 25, 27, 44, 52],
[08, 15, 16, 20, 29, 49],
[07, 23, 26, 31, 34, 41],
[01, 20, 35, 36, 55, 60],
[03, 18, 24, 37, 44, 47],
[07, 15, 27, 36, 39, 40],
[04, 06, 18, 24, 29, 42],
[03, 05, 13, 22, 25, 31],
];
for (let i = 0; i < playedGames.length; i++) {
const game = playedGames[i];
let matchingNumbers = 0;
for (let j = 0; j < game.length; j++) {
const number = game[j];
if (pickedNumbers.includes(number)) {
matchingNumbers += 1;
}
}
console.log(`${matchingNumbers} match(es) found on game ${game}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment