Problem 46072. Rock Paper Scissors Lizard Spock

Solution 2789173

Submitted on 5 Aug 2020 by Tim
  • Size: 43
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
assert(isequal(rpsls("rock","win"), {l, sc})|| isequal(rpsls("rock","win"), {sc, l}))

2   Pass
assert(isequal(rpsls("rock","lose"), {sp, p}) || isequal(rpsls("rock","lose"), {p, sp}))

3   Pass
assert(isequal(rpsls("rock","tie"), r))

4   Pass
assert(isequal(rpsls("paper","win"), {sp, r}) || isequal(rpsls("paper","win"), {r,sp}))

5   Pass
assert(isequal(rpsls("paper","lose"), {sc, l}) || isequal(rpsls("paper","lose"), {l, sc}))

6   Pass
assert(isequal(rpsls("paper","tie"), p))

7   Pass
assert(isequal(rpsls("scissors","win"), {l, p}) || isequal(rpsls("scissors","win"), {p, l}))

8   Pass
assert(isequal(rpsls("scissors","lose"), {r, sp}) || isequal(rpsls("scissors","lose"), {sp, r}))

9   Pass
assert(isequal(rpsls("scissors","tie"), sc))

10   Pass
assert(isequal(rpsls("lizard","win"), {p, sp}) || isequal(rpsls("lizard","win"), {sp, p}))

11   Pass
assert(isequal(rpsls("lizard","lose"), {sc, r}) || isequal(rpsls("lizard","lose"), {r, sc}))

12   Pass
assert(isequal(rpsls("lizard","tie"), l))

13   Pass
assert(isequal(rpsls("Spock","win"), {r, sc}) || isequal(rpsls("Spock","win"), {sc, r}))

14   Pass
assert(isequal(rpsls("Spock","lose"), {p, l}) || isequal(rpsls("Spock","lose"), {l, p}))

15   Pass
assert(isequal(rpsls("Spock","tie"), sp))

Suggested Problems

More from this Author1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!