Problem 46072. Rock Paper Scissors Lizard Spock
Can't decide what to watch on TV? How about settling the dispute with a good old fashioned round of Paper Scissors Lizard Spock ? Given your opponents choice and a strategy ("win", "lose", or "tie"), return a string representing the choice(s) that would yield that desired outcome.
Ex:
rpsls("rock","lose")
ans = {"Spock", "paper"} %%you will lose if you choose either Spock or paper
rpsls("paper", "tie")
ans = "paper" %%you will tie if you select the same choice
Solution Stats
Problem Comments
-
6 Comments
Show
3 older comments
Hope Dargan
on 4 Aug 2020
Should be fixed now to accept any order of two elements. Thanks for the feedback!
Tim
on 5 Aug 2020
Thank you. :-)
ChrisR
on 8 Aug 2020
Thanks Hope. There's also the issue that I've been muttering "Rock, Paper, Scissors, Lizard, Spock" as an earworm since solving this problem, but I suppose there's nothing you can do to fix that.
Solution Comments
Show commentsProblem Recent Solvers20
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6364 Solvers
-
Calculate the height of an object dropped from the sky
259 Solvers
-
5349 Solvers
-
Replace Nonzero Numbers with 1
406 Solvers
-
Calculate Amount of Cake Frosting
26142 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!