3 ms·
Rock, Scissors, Paper in a circular array. All you have to do to test for win condition is check if the other player has the next item in the array. Equality
by busterarm 8y ago
Rock, Scissors, Paper in a circular array.
All you have to do to test for win condition is check if the other player has the next item in the array.
Equality is a tie.
Base case is a loss.
It's also my favorite case of structuring data in a way that makes the algorithm self-evident.