Skip to content

Instantly share code, notes, and snippets.

View kzlsakal's full-sized avatar
💭
Yes

Doruk Gurleyen kzlsakal

💭
Yes
View GitHub Profile
@kzlsakal
kzlsakal / rockPaperScissors.js
Created October 2, 2020 19:27
Rock Paper Scissors JavaScript Permutation Solution (pre-ES6)
var rockPaperScissors = function (n) {
// Capture the n or give it a default value of 3
n = n || 3;
// Store the possible moves
const moves = ['R', 'P', 'S'];
// Store the possible game outcomes
const possibilities = [];
// Iterate on the number of options by the power of number of rounds
for (let i = 0; i < moves.length ** n; i++) {
// Store the current game outcome of all rounds