# Algorithm #01 "rock, paper, scissors"

filoscoderΒ·2019λ 11μ 22μΌ
0

## Toy Algorithm

1/7

πΊπΈ Complete the function that generates every possible sequence of shoots that a player could shot. [ rock / paper / scissors ]

π¦π· Completa la funcion que genere todas las secuencias posibles de tiros que un jugador pueda tirar. [ piedra / papel / tijera ] (traducido)

π°π· λμ μκ° λμ§ μ μλ λͺ¨λ  κ²½μ°μ μλ₯Ό μμ°νλ ν¨μμ κΈ°λ₯μ μλ£νμΈμ. [ κ°μ / λ°μ / λ³΄ ] (λ²μ­)

#### Example:

Your output should look something like:

// Test
rockPaperScissors();

// Output -> Array of arrays
// All the posible shots
[
["rock", "rock", "rock"],
["rock", "rock", "paper"],
["rock", "rock", "scissors"],
["rock", "paper", "rock"]
//    ...etc...
];

## # START [ here ] π

var rockPaperScissors = function(num) {
var shot = ["rock", "paper", "scissors"];
};

// Test
rockPaperScissors();

## # Javascript solution π

• Run it on your browser console window (F12) π₯
• Do your best to complete the problem π­
• if you can't beat this the solution is below π±

#### solution π

.
.
.
.
.
.
.
.
.
.
.

var rockPaperScissors = function() {
var shot = ["rock", "paper", "scissors"];
let solution = [];

for (let i = 0; i < shot.length; i++) {
for (let j = 0; j < shot.length; j++) {
for (let k = 0; k < shot.length; k++) {
var temp = [];
temp.push(shot[i], shot[j], shot[k]);
solution.push(temp);
}
}
}
return solution;
};

// Test
console.log(rockPaperScissors());
Never gets bored of making mistakes and wonder why is that