Ad
Code
Diff
  • def rock_paper_scissor_lizard_spock(p1, p2):
        hashmap = {'rock': ['scissors', 'lizard'],
                   'paper': ['spock', 'rock'],
                   'scissors': ['paper', 'lizard'],
                   'lizard': ['spock', 'paper'],
                   'spock': ['scissors', 'rock']}
        
        return 'Draw!' if p1 == p2 else 'Player 1 wins!' if p2 in hashmap[p1] else 'Player 2 wins!'
    • def rock_paper_scissor_lizard_spock(p1:str, p2:str)-> str:
    • def rock_paper_scissor_lizard_spock(p1, p2):
    • hashmap = {'rock': ['scissors', 'lizard'],
    • 'paper': ['spock', 'rock'],
    • 'scissors': ['paper', 'lizard'],
    • 'lizard': ['spock', 'paper'],
    • 'spock': ['scissors', 'rock']}
    • return 'Draw!' if p1 == p2 else 'Player 1 wins!' if p2 in hashmap[p1] else 'Player 2 wins!'