# Rock Paper Scissors

Let's play! You have to return which player won! In case of a draw return `Draw!`.

Examples:

![rockpaperscissors](http://i.imgur.com/aimOQVX.png)

Difficulty: introductory

Starter code:

def rps(p1, p2):
	

Solutions:
def rps(p1, p2):
    beats = {'rock': 'scissors', 'scissors': 'paper', 'paper': 'rock'}
    if beats[p1] == p2:
        return "Player 1 won!"
    if beats[p2] == p1:
        return "Player 2 won!"
    return "Draw!"

def rps(p1, p2):
    hand = {'rock':0, 'paper':1, 'scissors':2}
    results = ['Draw!', 'Player 1 won!', 'Player 2 won!']
    return results[hand[p1] - hand[p2]]

def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
    elif (p1 == 'rock' and p2 == 'scissors') or (p1 == 'scissors' and p2 == 'paper') or (p1 == 'paper' and p2 == 'rock'):
        return 'Player 1 won!'
    else:
        return 'Player 2 won!'


def rps(p1, p2):
    #your code here
    winner = {"scissors": "paper", "paper": "rock", "rock": "scissors"}
    if p1==p2:
        return 'Draw!'
    elif winner[p1]==p2:
        return "Player 1 won!"
    elif winner[p2]==p1:
        return "Player 2 won!"


RPS = {('rock', 'rock'): 'Draw!',
       ('rock', 'paper'): 'Player 2 won!',
       ('rock', 'scissors'): 'Player 1 won!',
       ('paper', 'rock'): 'Player 1 won!',
       ('paper', 'paper'): 'Draw!',
       ('paper', 'scissors'): 'Player 2 won!',
       ('scissors', 'rock'): 'Player 2 won!',
       ('scissors', 'paper'): 'Player 1 won!',
       ('scissors', 'scissors'): 'Draw!'}


def rps(p1, p2):
    return RPS[(p1, p2)]


def rps(p1, p2):
    if p1 == p2: return "Draw!"
    if p1 == "rock":
        if p2 == "paper": return "Player 2 won!"
        else: return "Player 1 won!"
    if p1 == "paper":
        if p2 == "scissors": return "Player 2 won!"
        else: return "Player 1 won!"
    if p1 == "scissors":
        if p2 == "rock": return "Player 2 won!"
        else: return "Player 1 won!"

def rps(p1, p2):
    if p1 == p2:
        return "Draw!"
    elif p1 == 'rock' and p2 == 'scissors':
        return "Player 1 won!"
    elif p1 == 'scissors' and p2 == 'paper':
        return "Player 1 won!"
    elif p1 == 'paper' and p2 == 'rock':
        return "Player 1 won!"
    else:
        return "Player 2 won!"

rps = lambda a, b: ['Draw!', 'Player 1 won!', 'Player 2 won!'][('srp'.index(a[0]) - 'srp'.index(b[0])) % 3]

def rps(p1, p2):
    d1 = [('paper','rock'), ('rock', 'scissors'), ('scissors', 'paper')]
    return 'Draw!' if p1 == p2 else "Player {} won!".format(1 if (p1, p2) in d1 else 2)

def rps(p1, p2):
    if p1 == p2:
        return "Draw!"
    
    rock_sciss = p1=="rock" and p2=="scissors"
    paper_rock = p1=="paper" and p2=="rock"
    sciss_paper = p1=="scissors" and p2=="paper"
    
    if rock_sciss or paper_rock or sciss_paper:
        return "Player 1 won!"
    else:
        return "Player 2 won!"

def rps(p1, p2):
  if p1 == p2: return "Draw!"
  return "Player 1 won!" if (p1[0] + p2[0]) == "sp" or (p1[0] + p2[0]) == "rs" or (p1[0] + p2[0]) == "pr" else "Player 2 won!"

def rps(p1, p2):
    options = ["rock", "paper", "scissors"]
    outcomes = ["Draw!", "Player 1 won!", "Player 2 won!"]
    return outcomes[options.index(p1) - options.index(p2)]

def rps(p1, p2):
    return f"Player {1+(p1[0]+p2[0] in 'psrp')} won!" if p1 != p2 else 'Draw!'

def rps(p1, p2):

    if p1 == p2:
        return 'Draw!'
        
    favourable_matchups = {'rock': 'scissors', 'scissors': 'paper', 'paper': 'rock'}
    return 'Player 1 won!' if favourable_matchups[p1] == p2 else 'Player 2 won!'

def rps(p1, p2):
    a = ['paper', 'rock', 'scissors']
    if p1 == p2: return "Draw!"
    return "Player 1 won!" if ((p1 == a[0] and p2 == a[1]) or (p1 == a[1] and p2 == a[2]) or (p1 == a[2] and p2 == a[0])) else "Player 2 won!"

rps = lambda p1, p2, l=["rock","paper","scissors"]: 'Draw!' if p1==p2 else 'Player {} won!'.format(1 + (l.index(p2)-l.index(p1) in [1,-2]))

def rps(p1, p2):
    return p1 == p2 and 'Draw!' or f"Player {(p2[0] + p1[0] in 'rspr') + 1} won!"

def rps(p1, p2):
    nums = ['rock', 'scissors', 'paper']    
    p1 = nums.index(p1)
    p2 = nums.index(p2)
    
    if p1 == p2:
        return 'Draw!'
    elif ((p2-p1) % 3 == 1):
        return 'Player 1 won!'
    else:
        return 'Player 2 won!'


BEATS = {'rock': 'scissors', 'scissors': 'paper', 'paper': 'rock'}

def rps(p1, p2):
    return 'Draw!' if p1 == p2 else __winner(p1, p2)

def __winner(p1, p2): 
    return 'Player 1 won!' if BEATS[p1] == p2 else 'Player 2 won!'


rps=lambda p1, p2: (lambda a: "Draw!" if a==0 else "Player 1 won!" if a%3==2 else "Player 2 won!")(['paper', 'rock', 'scissors'].index(p1) - ['paper', 'rock', 'scissors'].index(p2))

def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
    else:
        if (p1,p2) in [('rock', 'scissors'),('scissors', 'paper'),('paper', 'rock')]:
            return "Player 1 won!"
        else:
            return "Player 2 won!"
            


def rps(p1, p2):
    if p1 == p2:
        return "Draw!"
    elif (p1, p2) in [('scissors', 'paper'), ('paper', 'rock'), ('rock', 'scissors')]:
        return "Player 1 won!"
    else:
        return "Player 2 won!"

def rps(p1, p2):
    d = dict(rock=0, paper=1, scissors=2)
    return ('Draw!', 'Player 1 won!', 'Player 2 won!')[(d[p1] - d[p2]) % 3]

def rps(*args):
    return ("Draw!" if len(set(args)) == 1
            else "Player {} won!".format(1 + args.index("rock" if set(args) == {"rock", "scissors"}
                                                        else max(args, key=len))))

def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
        
    game_map = {
                ('rock', 'scissors'): 'rock', 
                ('scissors', 'paper'): 'scissors', 
                ('paper', 'rock'): 'paper'
              }
    winner = game_map.get((p1, p2), False) or game_map.get((p2, p1), False)
    return "Player 1 won!" if p1 == winner else "Player 2 won!"

def rps(p1, p2):
    return "Draw!" if p1 == p2 else "Player {} won!".format(-~(p2[0] + p1[0] in "rspr"))

def rps(p1, p2):
    rule = {'scissors':'paper', 'paper':'rock','rock':'scissors'}
    return ['Player %d won!'%[2,1][rule[p1]==p2],'Draw!'][p1==p2]

def rps(p1, p2):
    p1c = ['p1rp2s', 'p1sp2p', 'p1pp2r']
    p2c = ['p1sp2r', 'p1pp2s', 'p1rp2p']
    p1w = "Player 1 won!"
    p2w = "Player 2 won!"
    p3w = "Draw!"
    i = "p1{}p2{}".format(p1[0], p2[0])
    return p1w if i in p1c else p2w if i in p2c else p3w
    


def rps(p1, p2):
    r = 'rock'
    p = 'paper'
    s = 'scissors'
    p1w = 'Player 1 won!'
    p2w = 'Player 2 won!'
    if p1 == r and p2 == s: return p1w
    if p1 == r and p2 == p: return p2w
    if p1 == p and p2 == s: return p2w
    if p1 == p and p2 == r: return p1w
    if p1 == s and p2 == r: return p2w
    if p1 == s and p2 == p: return p1w
    else: return 'Draw!'


def rps(p1: str, p2: str) -> str:
    """ Get information which player won! In case of a draw return Draw! """

    score_rules = {
        "scissors": {"paper": True, "rock": False},
        "paper": {"scissors": False, "rock": True},
        "rock": {"scissors": True, "paper": False}
    }
    if p1 == p2:
        return "Draw!"
    elif score_rules.get(p1).get(p2):
        return "Player 1 won!"
    else:
        return "Player 2 won!"

def rps(p1, p2):
    m = ['rock', 'paper', 'scissors']
    return ["Draw!", "Player 1 won!", "Player 2 won!"][m.index(p1) - m.index(p2)]


def rps(p1, p2):
    res = ("rsp".find(p2[0]) - "rsp".find(p1[0]))%3
    return f"Player {res} won!" if res else "Draw!"

def rps(p1, p2):
    game = "rock", "paper", "scissors"
    if p1 == "scissors" and p2 == "paper":
        return "Player 1 won!"
    elif p1 == "rock" and p2 == "scissors":
        return "Player 1 won!"
    elif p1 == "paper" and p2 == "rock":
            return "Player 1 won!"
    
    #for player 2
    if p1 == "scissors" and p2 == "rock":
        return "Player 2 won!"
    elif p1 == "paper" and p2 == "scissors":
        return "Player 2 won!"
    elif p1 == "rock" and p2 == "paper":
        return "Player 2 won!"
    
    #for draw
    
    elif p1 == "rock" and p2 == "rock":
        return "Draw!"
    elif p1 == "scissors" and p2 == "scissors":
        return "Draw!"
    elif p1 == "paper" and p2 == "paper":
        return "Draw!"

def rps(p1, p2):
    if p1 == p2:
        return "Draw!"
    elif [p1, p2] in [["rock", "scissors"], ["scissors", "paper"], ["paper", "rock"]]:
        return "Player 1 won!"
    else:
        return "Player 2 won!"

def rps(p1, p2):
    beat_dict = {"scissors":"paper","paper":"rock","rock":"scissors"}
    return "Draw!" if p1 == p2 else "Player 1 won!" if beat_dict[p1] == p2 else "Player 2 won!"

def rps(p1, p2):
    values = {'rock':0, 'scissors': 1, 'paper': 2}
    if (values[p1] - values[p2])%3 == 0:
        return 'Draw!'
    elif (values[p1] - values[p2])%3 == 2:
        return 'Player 1 won!'
    else:
        return 'Player 2 won!'

def rps(p1, p2):
    rule = {'scissors':'paper', 'paper':'rock','rock': 'scissors'}
    if p1==p2:
        return 'Draw!'
    elif rule[p1] == p2:
        return 'Player 1 won!'
    else:
        return 'Player 2 won!'

def rps(p1, p2):
    if (p1 == 'rock' and p2 == 'scissors') or (p1 == 'scissors' and p2 == 'paper') or (p1 == 'paper' and p2 == 'rock'):
        return 'Player 1 won!'
    elif p1 == p2:
        return 'Draw!'
    else:
        return 'Player 2 won!'


def rps(p1, p2):
    moves = {'scissors':'paper', 'paper':'rock', 'rock':'scissors'}
    if p1 == p2: return "Draw!"
    if moves[p1] == p2: return "Player 1 won!"
    return "Player 2 won!"

def rps(*players):
    result = "Draw!"
    if players[0] != players[1] :
        if ('rock' in players) and not ('paper' in players):
            winner = players.index('rock') +1
        elif ('paper' in players) and not ('scissors' in players):
            winner = players.index('paper') +1
        elif ('scissors' in players) and not ('rock' in players):
            winner = players.index('scissors') + 1
        result = "Player %s won!" %(winner)
            
    return result

def rps(p1, p2):
    rock = "rock"
    paper = "paper"
    scissors = "scissors"
    p1won = "Player 1 won!"
    p2won = "Player 2 won!"
    draw = 'Draw!'
    solutions = {rock: {rock: draw,
                        paper: p2won,
                        scissors: p1won,},
                 paper: {rock: p1won,
                         paper: draw,
                         scissors: p2won,},
                 scissors: {rock: p2won,
                            paper: p1won,
                            scissors: draw,},}
    return solutions[p1][p2]

def rps(p1, p2):
    #your code here
    if p1 == p2:
        return 'Draw!'
    if p1 == 'scissors' and p2 == 'paper' or p1 == 'rock' and p2 == 'scissors' or p1 =='paper' and p2 == 'rock':
        return 'Player 1 won!'
    else:
        return 'Player 2 won!'

P1_WINS = {'scissorspaper', 'paperrock', 'rockscissors'}


def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
    return 'Player {} won!'.format(1 if p1 + p2 in P1_WINS else 2)


def rps(p1, p2):
    v = { 'p': 1, 'r': 0, 's': -1 }
    return 'Draw!' if p1 == p2 else 'Player 1 won!' if v[p1[0]] - v[p2[0]] in [1, -2] else 'Player 2 won!'


def rps(p1, p2):
    print(p1,p2)
    if p1 == p2:
        return "Draw!"
    elif p1=="scissors" and p2=="paper":
        return "Player 1 won!"
    elif p1=="scissors" and p2=="rock":
        return "Player 2 won!"
    elif p1=="rock" and p2=="scissors":
        return "Player 1 won!"
    elif p1=="rock" and p2=="paper":
        return "Player 2 won!"
    elif p1=="paper" and p2=="rock":
        return "Player 1 won!"
    elif p1=="paper" and p2=="scissors":
        return "Player 2 won!"

def rps(p1, p2):
    if p1 == p2:
        return 'Draw!' 
    elif p1 == 'rock' or p1 == 'scissors' or p1 == 'paper':
        return 'Player 1 won!' if p2 != 'rock' and p1 == 'scissors' or p2 != 'paper' and p1 == 'rock' or p2 != 'scissors' and p1 == 'paper' else 'Player 2 won!'
    
    




def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
    elif p1 == "rock" and p2 == 'scissors':
        return "Player 1 won!"
    elif p1 == "scissors" and p2 == 'paper':
        return "Player 1 won!"
    elif p1 == "paper" and p2 == 'rock':
        return "Player 1 won!"
    return  "Player 2 won!"

def rps(p1, p2):
    r, s, p = 'rock', 'scissors', 'paper'
    if p1 == p2:
        return "Draw!"
    elif (p1,p2) in [(r,s), (s,p), (p,r)]:
        return 'Player 1 won!'
    else:
        return 'Player 2 won!'


def rps(p1, p2):
    if p1 == 'scissors' and p2 == 'paper':
        return 'Player 1 won!'
    elif p2 == p1:
        return 'Draw!'
    elif p1 == 'rock' and p2 == 'scissors':
        return 'Player 1 won!'
    elif p1 == 'paper' and p2 == 'rock':
        return 'Player 1 won!'
    else:
        return 'Player 2 won!'

def rps(p1, p2):
    if p1 == p2:
        return "Draw!"
    elif p1 == "scissors":
        if p2 == "rock":
            return "Player 2 won!"
        elif p2 == "paper":
            return "Player 1 won!"
    elif p1 == "paper":
        if p2 == "scissors":
            return "Player 2 won!"
        elif p2 == "rock":
            return "Player 1 won!"
    elif p1 == "rock":
        if p2 == "scissors":
            return "Player 1 won!"
        elif p2 == "paper":
            return "Player 2 won!"

def rps(p1, p2):
    if p1 == p2: return "Draw!"
    dic = {"rs": 1, "sp": 1, "ps": 2, "sr": 2, "pr": 1, "rp": 2}
    return f"Player {dic[p1[0] + p2[0]]} won!"

def rps(p1, p2):
    if p1 == 'rock':
        if p2 == 'paper':
            return 'Player 2 won!'
        elif p2 == 'scissors':
            return 'Player 1 won!'
        else:
            return 'Draw!'
    elif p1 == 'paper':
        if p2 == 'rock':
            return 'Player 1 won!'
        elif p2 == 'scissors':
            return 'Player 2 won!'
        else:
            return 'Draw!'
    else:
        if p2 == 'rock':
            return 'Player 2 won!'
        elif p2 == 'paper':
            return 'Player 1 won!'
        else:
            return 'Draw!'

def rps(p1, p2):
    items = {'rock':0, 'paper':1, 'scissors':2}
    if p1=='rock' and p2=='scissors':
        return "Player 1 won!"
    elif p2=='rock' and p1=='scissors':
        return "Player 2 won!"
    
    if items[p1] > items[p2]:
        return  "Player 1 won!"
    elif items[p1] == items[p2]:
        return "Draw!"
    else:
        return "Player 2 won!"


def rps(p1, p2):
    d= {'scissors': 'paper', 'rock': 'scissors', 'paper': 'rock'}
    return 'Draw!' if p1 == p2 else 'Player 1 won!' if d[p1] == p2 else 'Player 2 won!'


def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
    elif p1 == 'rock':
        if p2 == 'scissors':
            return 'Player 1 won!'
        else:
            return 'Player 2 won!'
    elif p1 == 'scissors':
        if p2 == 'rock':
            return 'Player 2 won!'
        else:
            return 'Player 1 won!'
    elif p1 == 'paper':
        if p2 == 'scissors':
            return 'Player 2 won!'
        else:
            return 'Player 1 won!'

def rps(p1, p2):
    x=('rock','scissors','paper')
    y=('rock','scissors','paper')
    if p1 == p2:
        return "Draw!"
    elif p1 == x[0] and p2 == y[1]: 
        return "Player 1 won!" 
    elif p1 == x[1] and p2 == y[2]: 
        return "Player 1 won!" 
    elif p1 == x[2] and p2 == y[0]: 
        return "Player 1 won!" 
    else:
        return "Player 2 won!"
    #your code here


winner = lambda a, b: {'scissors': 'paper', 'rock' : 'scissors', 'paper': 'rock'}[a] == b

def rps(p1, p2):
    return 'Draw!' if p1 == p2 else ('Player 1 won!' if winner(p1, p2) else 'Player 2 won!')

def rps(p1, p2):
    if p1 == p2:
        return "Draw!"
    elif p1 == "scissors" and p2 == "paper":
        return "Player 1 won!"
    elif p1 == "rock" and p2 == "scissors":
        return "Player 1 won!"
    elif p1 == "paper" and p2 == "rock":
        return "Player 1 won!"
    else:
        return "Player 2 won!"
    
"""    if p1 == p2:
        return "Draw!"
    elif p1[0].lower == "s" and p2[0].lower == "p":
        return "Player 1 won!"
    elif p1[0].lower == "r" and p2[0].lower == "s":
        return "Player 1 won!"
    elif p1[0].lower == "p" and p2[0].lower == "r":
        return "Player 1 won!"
    else:
        return "Player 2 won!"
"""    
r1 = "rock"
r2 = "scissors"

print(rps(r1,r2))

def rps(p1, p2):
    if p1==p2:
        return "Draw!"
    elif "scissors" in p1:
        if "rock" in p2:
            return "Player 2 won!"
        elif "paper" in p2:
            return "Player 1 won!"
    elif "rock" in p1:
        if "paper" in p2:
            return "Player 2 won!"
        elif "scissors" in p2:
            return "Player 1 won!"
    elif "paper" in p1:
        if "scissors" in p2:
            return "Player 2 won!"
        elif "rock" in p2:
            return "Player 1 won!"

def rps(a:str,b:str):
  c:str = "Player 1 won!"
  d:str = "Player 2 won!"
  e:str = "Draw!"  
  if a == "rock" and b == "scissors":
    return c
  if a == "scissors" and b == "paper":
    return c
  if a == "paper" and b == "rock":
    return c
  if a == "rock" and b == "paper":
    return d
  if a == "scissors" and b == "rock":
    return d
  if a == "paper" and b == "scissors":
    return d
  else:
    return e    

def rps(p1, p2):
    print(p1, p2)
    if p1 == p2:
        return "Draw!"
    if p1 == 'scissors' and p2 != 'rock':
        return "Player 1 won!"
    if p1 == 'scissors' and p2 == 'rock':
        return "Player 2 won!"
    if p2 == 'scissors' and p1 != 'rock':
        return "Player 2 won!"
    if p2 == 'scissors' and p1 == 'rock':
        return "Player 1 won!"
    if p1 == "paper" and p2 != 'scissors':
        return "Player 1 won!"
    if p1 == 'paper' and p2 == 'scissors':
        return "player 2 won!"
    if p2 == 'paper' and p1 != 'scissors':
        return "Player 2 won!"
    if p2 == 'paper' and p1 == 'scissors':
        return "player 1 won!"

def rps(p1, p2):
    if p1 == 'scissors':
        if p2 == 'paper':
            return 'Player 1 won!'
        elif p2 == 'rock':
            return 'Player 2 won!'
        elif p2 == p1:
            return 'Draw!'
    if p2 == 'scissors':
        if p1 == 'paper':
            return 'Player 2 won!'
        elif p1 == 'rock':
            return 'Player 1 won!'
        elif p1 == p2:
            return 'Draw!'
    if p1 == 'rock':
        if p2 == 'paper':
            return 'Player 2 won!'
        elif p2 == p1:
            return 'Draw!' 
    if p1 == 'paper':
        if p2 == 'rock':
            return 'Player 1 won!'
        elif p2 == p1:
            return 'Draw!' 



def rps(p1, p2):
    #your code here
    #draw
    if p1 == p2:
        return 'Draw!'
    #player 1 won
    if p1 == 'rock' and p2 == 'scissors':
        return 'Player 1 won!'
    if p1 == 'scissors' and p2 == 'paper':
        return 'Player 1 won!'
    if p1 == 'paper' and p2 == 'rock':
        return 'Player 1 won!'
    #player 2 won
    if p2 == 'rock' and p1 == 'scissors':
        return 'Player 2 won!'
    if p2 == 'scissors' and p1 == 'paper':
        return 'Player 2 won!'
    if p2 == 'paper' and p1 == 'rock':
        return 'Player 2 won!'

def rps(p1, p2):
    rules = {
        'rock':'scissors',
        'scissors':'paper',
        'paper':'rock'
    }
    
    if   rules.get(p1)==p2:  a = 1           # Player 1 won
    elif rules.get(p2)==p1:  a = 2           # Player 2 won
    else:                    return 'Draw!'  # Draw
    
    return f'Player {a} won!'

def rps(p1, p2):
    game = ['rock', 'paper', 'scissors']
    s1, s2 = game.index(p1), game.index(p2)
    if s1 == s2:
        return 'Draw!'
    if (s1 == 0 and s2 == 2) or (s1 == 2 and s2 == 1) or (s1 == 1 and s2 == 0):
        return 'Player 1 won!'
    return 'Player 2 won!'

def rps(p1, p2):
    if p1 == "rock":
        if p2 == "scissors":
            return "Player 1 won!"
        elif p1 == p2:
            return "Draw!"
        else:
            return "Player 2 won!"
    if p1 == "scissors":
        if p2 == "paper":
            return "Player 1 won!"
        elif p1 == p2:
            return "Draw!"
        else:
            return "Player 2 won!"
    if p1 == "paper":
        if p2 == "rock":
            return "Player 1 won!"
        elif p1 == p2:
            return "Draw!"
        else:
            return "Player 2 won!"

def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
    if p1 == 'scissors':
        if p2 == 'paper':
            return "Player 1 won!"
        elif p2 == 'rock':
            return "Player 2 won!"
    elif p1 == 'rock': 
        if p2 == 'paper':
            return "Player 2 won!"
        elif p2 == 'scissors':
            return "Player 1 won!"
    else:
        if p2 == 'scissors':
            return "Player 2 won!"
        elif p2 == 'rock':
            return "Player 1 won!"


def rps(p1, p2):
    if p1 == 'scissors' and p2=='paper':
        return "Player 1 won!"
    if p1 == p2:
        return 'Draw!'
    if p1== 'scissors' and p2== 'rock':
        return "Player 2 won!"
    if p1 == 'paper' and p2=='rock':
        return "Player 1 won!"
    if p2 == 'scissors' and p1=='paper':
        return "Player 2 won!"
    if p2== 'scissors' and p1== 'rock':
        return "Player 1 won!"
    if p2 == 'paper' and p1=='rock':
        return "Player 2 won!"
    
    
        
        
       
    #your code here


def rps(p1, p2):
    if p1 == p2:
        return "Draw!"
    if p1 == "paper" and p2 == "rock" or p1 == "scissors" and p2 == "paper" or p1 == "rock" and p2 == "scissors":
        return "Player 1 won!"
    return "Player 2 won!"

def rps(p1, p2):
    result = [p1, p2]
    if result[0] == 'rock':
        if result[1] == 'paper':
            return 'Player 2 won!'
        if result[1] == 'rock':
            return 'Draw!'
        if result[1] == 'scissors':
            return 'Player 1 won!'
    elif result [0] == 'paper':
        if result[1] == 'rock':
            return 'Player 1 won!'
        if result[1] == 'paper':
            return 'Draw!'
        if result[1] == 'scissors':
            return 'Player 2 won!'
    elif result[0] == 'scissors':
        if result[1] == 'scissors':
            return 'Draw!'
        if result[1] == 'paper':
            return "Player 1 won!"
        if result[1] == 'rock':
            return 'Player 2 won!'

def rps(p1, p2):
    if p1=='scissors' and p2=='paper':
        resultado = "Player 1 won!"
    elif p1=='scissors' and p2=='rock':
        resultado ="Player 2 won!"
    elif p1=='paper' and p2=='rock':
        resultado = "Player 1 won!"
    elif p1=='paper' and p2=='scissors':
        resultado= "Player 2 won!"
    elif p1=='rock' and p2=='paper':
        resultado = "Player 2 won!"
    elif p1=='rock' and p2=='scissors':
        resultado = "Player 1 won!"
    else:
        resultado = "Draw!"
    return resultado
    


def rps(p1, p2):
    pairs = {"scissors" : "paper", "paper" : "rock", "rock" : "scissors"}
    if pairs[p1] == p2:
        return 'Player 1 won!'
    elif pairs[p2] == p1:
        return 'Player 2 won!'
    else:
        return 'Draw!'

def rps(p1, p2):
    if p1=='scissors' and p2=='paper':
        return 'Player 1 won!'
    elif p1=='scissors' and p2=='rock':
        return 'Player 2 won!'
    elif p1=='scissors' and p2=='scissors':
        return 'Draw!'
    elif p1=='paper' and p2=='scissors':
        return 'Player 2 won!'
    elif p1=='paper' and p2=='rock':
        return 'Player 1 won!'
    elif p1=='paper' and p2=='paper':
        return 'Draw!'
    elif p1=='rock' and p2=='paper':
        return 'Player 2 won!'
    elif p1=='rock' and p2=='scissors':
        return 'Player 1 won!'
    elif p1=='rock' and p2=='rock':
        return 'Draw!'
    #your code here


def rps(p1, p2):
    if p1 == 'rock' and p2 == 'scissors':
        return "Player 1 won!"
    elif p1 == 'paper' and p2 == 'rock':
        return "Player 1 won!"
    elif p1 == 'scissors' and p2 == 'paper':
        return "Player 1 won!"
    if p2 == 'rock' and p1 == 'scissors':
        return "Player 2 won!"
    elif p2 == 'paper' and p1 == 'rock':
        return "Player 2 won!"
    elif p2 == 'scissors' and p1 == 'paper':
        return "Player 2 won!"
    else:
        return "Draw!"


def rps(p1, p2):
    if p1 == p2: return "Draw!"
    rps = {"rock":2,"scissors":1,"paper":0}
    if p1 == "rock" and p2 == "paper" or  p1 == "paper" and p2 == "rock":
        rps["paper"] = 3
    return "Player 1 won!" if rps[p1] > rps[p2] else "Player 2 won!"


def rps(p1, p2):
    #player 1
    if p1 == "scissors" and p2 == "paper":
        return "Player 1 won!"
    elif p1 == "paper" and p2 == "rock":
        return "Player 1 won!"
    elif p1 == "rock" and p2 == "scissors":
        return "Player 1 won!"
    #player 2 
    elif p1 == "scissors" and p2 == "rock":
        return "Player 2 won!"
    elif p1 == "paper" and p2 == "scissors":
        return "Player 2 won!"
    elif p1 == "rock" and p2 == "paper":
        return "Player 2 won!"
    else:
        return "Draw!"

def rps(p1, p2):
    if p1 == 'rock':
        if p2 == p1:
            return "Draw!"
        elif p2  == 'scissors':
            return "Player 1 won!"
        else:
            return "Player 2 won!"
    elif p1 == 'paper':
        if p2 == p1:
            return "Draw!"
        elif p2  == 'scissors':
            return "Player 2 won!"
        else:
            return "Player 1 won!"
    else:
        if p2 == p1:
            return "Draw!"
        elif p2  == 'paper':
            return "Player 1 won!"
        else:
            return "Player 2 won!"

def rps(p1, p2):
    score = {"rock":1, "paper":2, "scissors":3}
    if p1==p2:
        return "Draw!"
    elif (score[p1]-score[p2])%3 > 1:
        return "Player 2 won!"
    else:
        return "Player 1 won!"

def rps(p1, p2):
    if p1 == "scissors" and p2 == "paper":
        return "Player 1 won!"
    if p1 == "paper" and p2 == "rock":
        return "Player 1 won!"
    if p1 == "rock" and p2 == "scissors":
        return "Player 1 won!"
    return "Draw!" if p1==p2 else "Player 2 won!" 

def rps(p1, p2):
    dict = {"rock": 0, "paper": 1, "scissors": 2}
    gameover = ["Draw!", "Player 1 won!", "Player 2 won!"]
    
    return gameover[(dict[p1] + -dict[p2]) % 3]
    #your code here


def rps(p1, p2):
    if p1=='rock' and p2=='scissors':
        return "Player 1 won!"
    if p1=='rock' and p2=='paper':
        return "Player 2 won!"
    if p1=='scissors' and p2=='rock':
        return "Player 2 won!"
    if p1=='scissors' and p2=='paper':
        return "Player 1 won!"
    if p1=='paper' and p2=='rock':
        return "Player 1 won!"
    if p1=='paper' and p2=='scissors':
        return "Player 2 won!"
    if p1=='paper' and p2=='paper':
        return "Draw!"
    if p1=='rock' and p2=='rock':
        return "Draw!"
    if p1=='scissors' and p2=='scissors':
        return "Draw!"


def rps(p1, p2):
    if p1 == 'scissors':
        if p2 == 'paper':
            return "Player 1 won!"
        elif p2 == 'rock':
            return "Player 2 won!"
        else:
            return "Draw!"
    if p1 == 'rock':
        if p2 == 'paper':
            return "Player 2 won!"
        elif p2 == 'scissors':
            return "Player 1 won!"
        else:
            return "Draw!"
    if p1 == 'paper':
        if p2 == 'scissors':
            return "Player 2 won!"
        elif p2 == 'rock':
            return "Player 1 won!"
        else:
            return "Draw!"

def rps(p1, p2):
    result = ''
    if p1 == 'rock' and p2 == 'scissors':
        result = "Player 1 won!"
    elif p1 == 'scissors' and p2 == 'paper':
        result = "Player 1 won!"
    elif p1 == 'paper' and p2 == 'rock':
        result = "Player 1 won!"
    elif p2 == 'rock' and p1 == 'scissors':
        result = "Player 2 won!"
    elif p2 == 'scissors' and p1 == 'paper':
        result = "Player 2 won!"
    elif p2 == 'paper' and p1 == 'rock':
        result = "Player 2 won!"
    else:
        result = 'Draw!'
    
    return result

beats = {
    'rock': 'scissors',
    'scissors': 'paper',
    'paper': 'rock'
}

def rps(p1, p2):
    if p1 == p2:
        return 'Draw!'
    
    if beats[p1] == p2:
        return 'Player 1 won!'
    
    return 'Player 2 won!'


def rps(p1, p2):
    win = [('paper', 'rock'),('scissors', 'paper'),('rock', 'scissors')]
    if  (p1, p2) in win: return "Player 1 won!" 
    if  (p2, p1) in win: return "Player 2 won!"
    else:  return "Draw!" 

def rps(p1, p2):
    if p1 == p2 :
        return 'Draw!'
    wins = {'rock': 'scissors' , 'scissors' : 'paper', 'paper' :'rock'}
    return 'Player 1 won!' if wins[p1] == p2 else 'Player 2 won!'


def rps(p1, p2):
    if p1[0] =="r" and p2[0] == "s":
        soluzione = "Player 1 won!"
    elif p1[0] == "p" and p2[0] == "s":
        soluzione = "Player 2 won!"
    elif p1[0] == "r" and p2[0] == "p":
        soluzione = "Player 2 won!"
    elif p1[0] == "p" and p2[0] == "r":
        soluzione = "Player 1 won!"
    elif p1[0] == "s" and p2[0] == "r":
        soluzione = "Player 2 won!"
    elif p1[0] == "s" and p2[0] == "p":
        soluzione = "Player 1 won!"
    else:
        soluzione = "Draw!"
    return soluzione

def rps(p1, p2):
    #your code here
    if (p1 == p2):
        return "Draw!"
    elif(p1 == 'scissors' and p2 == 'paper'):
        return 'Player 1 won!'
    elif(p1 == 'rock' and p2 == 'scissors'):
        return 'Player 1 won!'
    elif(p1 == 'paper' and p2 == 'rock'):
        return 'Player 1 won!'
    elif(p1 == 'rock' and p2 == 'paper'):
        return 'Player 2 won!'
    elif(p1 == 'scissors' and p2 == 'rock'):
        return 'Player 2 won!'
    elif(p1 == 'paper' and p2 == 'scissors'):
        return 'Player 2 won!'

def rps(p1, p2):
    r="rock"
    s="scissors"
    p="paper"
    if (p1==p and p2==r) or (p1==r and p2==s) or (p1==s and p2==p):
        return "Player 1 won!"
    elif p1==p2:
        return "Draw!"
    else:
        return "Player 2 won!"

def rps(p1, p2):
    return {
        p1=='rock' and p2=='scissors' or p1=='paper' and p2=='rock' or p1=='scissors' and p2=='paper' : 'Player 1 won!', p1==p2:'Draw!'
    }.get(1,'Player 2 won!')

def rps(p1, p2):
    return "Draw!" if p1==p2 else "Player 1 won!" if {'scissors': 'paper', 'paper': 'rock','rock': 'scissors'}.get(p1) == p2 else "Player 2 won!"

def rps(p1, p2):
    sc = 'scissors'
    pp = 'paper'
    rc = 'rock'
    inpt = [p1, p2]
    if inpt == [sc, pp] or inpt == [rc, sc] or inpt == [pp, rc]:
        return 'Player 1 won!'
    if inpt == [pp, sc] or inpt == [sc, rc] or inpt == [rc, pp]:
        return 'Player 2 won!'
    else:
        return 'Draw!'

def rps(p1, p2):
    return {
        'rockscissors': 'Player 1 won!',
        'scissorspaper': 'Player 1 won!',
        'paperrock': 'Player 1 won!',
        'scissorsrock': 'Player 2 won!',
        'paperscissors': 'Player 2 won!',
        'rockpaper': 'Player 2 won!',
        'rockrock': 'Draw!',
        'scissorsscissors': 'Draw!',
        'paperpaper': 'Draw!'
    }.get(p1+p2)

def wins(hand1, hand2):
    if hand1 == 'scissors' and hand2 == 'paper':
        return '1'
    elif hand1 == 'paper' and hand2 == 'rock':
        return '1'
    elif hand1 == 'rock' and hand2 == 'scissors':
        return '1'
    else:
        return '2'
    
def rps(p1, p2):
    if p1==p2:
        return 'Draw!'
    else:
        return 'Player ' + wins(p1,p2) + ' won!'

def rps(p1, p2):
    if p1 == "rock" and p2 == "scissors":
        return "Player 1 won!"
    elif p1 == "rock" and p2 == "paper":
        return "Player 2 won!"
    elif p1 == "rock" and p2 == "rock":
        return "Draw!"
    elif p1 == "paper" and p2 == "rock":
        return "Player 1 won!"
    elif p1 == "paper" and p2 == "scissors":
        return "Player 2 won!"
    elif p1 == "paper" and p2 == "paper":
        return "Draw!"
    elif p1 == "scissors" and p2 == "rock":
        return "Player 2 won!"
    elif p1 == "scissors" and p2 == "paper":
        return "Player 1 won!"
    elif p1 == "scissors" and p2 == "scissors":
        return "Draw!"

DRAW = 'Draw!'
P1_WIN = 'Player 1 won!'
P2_WIN = 'Player 2 won!'
gamestate = {
    'rock': {'rock': DRAW, 'paper': P2_WIN,'scissors': P1_WIN,},
    'paper': {'rock': P1_WIN, 'paper': DRAW,'scissors': P2_WIN,},
    'scissors':{'rock': P2_WIN, 'paper': P1_WIN,'scissors': DRAW,}
}

def rps(p1, p2):    
    return gamestate[p1][p2]



def rps2(p1, p2):
    if p1 == "scissors" and p2 == "paper":
        return "Player 1 won!"
    elif p1 == "scissors" and p2 == "rock":
        return "Player 2 won!"
    elif p1 == p2:
        return "Draw!"
    elif p1 == "paper" and p2 == "scissors":
        return "Player 2 won!"
    elif p1 == "paper" and p2 == "rock":
        return "Player 1 won!"
    elif p1 == "rock" and p2 == "scissors":
        return "Player 1 won!"
    elif p1 == "rock" and p2 == "paper":
        return "Player 2 won!"

def rps(p1, p2):
    win = {"scissors":"rock", "paper":"scissors", "rock":"paper"}
    return "Draw!" if p1 == p2 else "Player 2 won!" if p2 == win[p1] else "Player 1 won!" 

def rps(p1, p2):
    d = {("rock","scissors"):"Player 1 won!",
         ("paper","scissors"):"Player 2 won!",
         ("paper","rock"):"Player 1 won!",
         ("scissors","rock"):"Player 2 won!",
         ("scissors","paper"):"Player 1 won!",
         ("rock","paper"):"Player 2 won!",
         ("paper","paper"):"Draw!",
         ("rock","rock"):"Draw!",
         ("scissors","scissors"):"Draw!",}
    if (p1,p2) in d:
        return d[(p1,p2)]

def rps(p1, p2):
    if p1 == 'rock' and p2 == 'scissors':
        return "Player 1 won!"
    elif p1 == 'rock' and p2 == 'paper':
        return "Player 2 won!"
    elif p1 == 'scissors' and p2 == 'paper':
        return 'Player 1 won!'
    elif p1 == 'scissors' and p2 == 'rock':
        return 'Player 2 won!'
    elif p1 == 'paper' and p2 == 'rock':
        return 'Player 1 won!'
    elif p1 == 'paper' and p2 == 'scissors':
        return 'Player 2 won!'
    elif p1 == p2:
        return "Draw!"