Kodewick
Start learning →
Mini challenge←→0 / 70

Rock paper scissors

#017Mini challengeConditions6 min

A and B play rock paper scissors: 'R' rock, 'P' paper, 'S' scissors. Rock beats scissors, scissors beat paper, paper beats rock. Write rps(a, b) to return "draw" if they are the same, "A wins" if A wins and "B wins" if B wins.

Examples
rps('R', 'S')→'A wins'
rps('R', 'P')→'B wins'
rps('P', 'P')→'draw'
The functionconst char *rps(char a, char b)
main.c
const char *rps(char a, char b) {
    if (a == b) {
        return "draw";
    }
    // your code here: the three ways A wins: return "A wins"
    return "B wins";
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.