dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
2.4 KiB
2.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 6925e2068081f40f549ced1d | Challenge 139: Rock, Paper, Scissors | 29 | challenge-139 |
--description--
Given two strings, the first representing Player 1 and the second representing Player 2, determine the winner of a match of Rock, Paper, Scissors.
- The input strings will always be
"Rock","Paper", or"Scissors". "Rock"beats"Scissors"."Paper"beats"Rock"."Scissors"beats"Paper".
Return:
"Player 1 wins"if Player 1 wins."Player 2 wins"if Player 2 wins."Tie"if both players choose the same option.
--hints--
rock_paper_scissors("Rock", "Rock") should return "Tie".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(rock_paper_scissors("Rock", "Rock"), "Tie")`)
}})
rock_paper_scissors("Rock", "Paper") should return "Player 2 wins".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(rock_paper_scissors("Rock", "Paper"), "Player 2 wins")`)
}})
rock_paper_scissors("Scissors", "Paper") should return "Player 1 wins".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(rock_paper_scissors("Scissors", "Paper"), "Player 1 wins")`)
}})
rock_paper_scissors("Rock", "Scissors") should return "Player 1 wins".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(rock_paper_scissors("Rock", "Scissors"), "Player 1 wins")`)
}})
rock_paper_scissors("Scissors", "Scissors") should return "Tie".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(rock_paper_scissors("Scissors", "Scissors"), "Tie")`)
}})
rock_paper_scissors("Scissors", "Rock") should return "Player 2 wins".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(rock_paper_scissors("Scissors", "Rock"), "Player 2 wins")`)
}})
--seed--
--seed-contents--
def rock_paper_scissors(player1, player2):
return player1
--solutions--
def rock_paper_scissors(player1, player2):
if player1 == player2:
return "Tie"
if (player1 == "Rock" and player2 == "Scissors") or \
(player1 == "Paper" and player2 == "Rock") or \
(player1 == "Scissors" and player2 == "Paper"):
return "Player 1 wins"
else:
return "Player 2 wins"