Ad
Sets
Code
Diff
  • dumbRockPaperScissors=lambda a,b:('Draw','Player 1 wins','Player 2 wins')['RPS'.find(a[0])-'RPS'.find(b[0])]
    def rps (p1,p2):
        retval= {
            'R':{'R': 0, 'S':-1, "P": 1},
            'S':{'R': 1, 'S': 0, 'P':-1},
            'P':{'R':-1, 'S': 1, 'P':0}
        }
        return retval[p1][p2]
                   
    • dumbRockPaperScissors=lambda a,b:('Draw','Player 1 wins','Player 2 wins')['RPS'.find(a[0])-'RPS'.find(b[0])]
    • dumbRockPaperScissors=lambda a,b:('Draw','Player 1 wins','Player 2 wins')['RPS'.find(a[0])-'RPS'.find(b[0])]
    • def rps (p1,p2):
    • retval= {
    • 'R':{'R': 0, 'S':-1, "P": 1},
    • 'S':{'R': 1, 'S': 0, 'P':-1},
    • 'P':{'R':-1, 'S': 1, 'P':0}
    • }
    • return retval[p1][p2]