# Task
Two players - `"black"` and `"white"` are playing a game. The game consists of several rounds. If a player wins in a round, he is to move again during the next round. If a player loses a round, it's the other player who moves on the next round. Given whose turn it was on the previous round and whether he won, determine whose turn it is on the next round.



# Input/Output


`[input]` string `lastPlayer`/`$last_player`

`"black"` or `"white"` - whose move it was during the previous round.

`[input]` boolean `win`/`$win`

`true` if the player who made a move during the previous round won, `false` otherwise.

`[output]` a string

Return `"white"` if white is to move on the next round, and `"black"` otherwise.

# Example

For `lastPlayer = "black" and win = false`, the output should be `"white"`.

For `lastPlayer = "white" and win = true`, the output should be `"white"`.

Difficulty: introductory

Starter code:

def whoseMove(lastPlayer, win):
	

Solutions:
def whoseMove(lastPlayer, win):
    return lastPlayer if win else 'white' if lastPlayer == 'black' else 'black'

def whoseMove(lastPlayer, win):
    players = ['white', 'black']
    return lastPlayer if win else players[players.index(lastPlayer) - 1]

def whoseMove(lastPlayer, win):
    return ["white", "black"][(lastPlayer == "black") == win]

def whoseMove(lastPlayer, win):
    return ['black', 'white'][(lastPlayer == 'black') ^ win]

def whoseMove(lastPlayer, win):
    if lastPlayer == 'black':
        if win == True:
            return 'black'
        else:
            return 'white'
    else:
        if win == True:
            return 'white'
        else:
            return 'black'

def whoseMove(lastPlayer, win):
    return {"white", "black"}.difference({lastPlayer}).pop() if not win else lastPlayer


def whoseMove(lastPlayer, win):
  otherPlayer = "black" if lastPlayer == "white" else "white"
  return lastPlayer if win else otherPlayer


def whoseMove(lastPlayer, win):
    if lastPlayer == 'black':
        return ['black','white'][not win]
    return ['black','white'][win]

def whoseMove(lastPlayer, win):
    if lastPlayer=='black' and win:
        return 'black'
    elif lastPlayer=='white' and win:
        return 'white'
    elif lastPlayer=='white' and not win:
        return 'black'
    return 'white'

def whoseMove(lastPlayer, win):
    op = ['black', 'white']
    op.remove(lastPlayer)
    return lastPlayer if win else op[0]

def whoseMove(lastPlayer, win):
    return lastPlayer if win else ({'white','black'}-{lastPlayer}).pop()

whoseMove = lambda s, b: s if b else ('white' if s == 'black' else 'black')

def whoseMove(lastPlayer, win):
    if lastPlayer == 'black':
        return('black' if win else 'white')
    else:
        return('white' if win else 'black')

def whoseMove(lastPlayer, win):
    return lastPlayer if win else {'white':'black', 'black':'white'}.get(lastPlayer)

whoseMove = lambda l,w,a=["black","white"]: a[[not w,w][a.index(l)]]

def whoseMove(lastPlayer, win):
    return {'black':'white','white':'black'}.get(lastPlayer) if not win else lastPlayer

def whoseMove(last_player: str, win: bool) -> str:
    """ Get info whose turn is on the next round based on given last player's move and his result. """
    return ["white", "black"][
        any(
            [all([last_player == "black", win is True]),
             all([last_player == "white", win is False])]
        )
    ]

whoseMove=lambda b,w:'bwlhaictke'[(b<'w')+w&1::2]

def whoseMove(lastPlayer, win):
    return lastPlayer if win else {'black': 'white', 'white': 'black'}[lastPlayer]

def whoseMove(lastPlayer, win):
    lib = {'white': 'black', 'black':'white'}
    return lastPlayer if win == True else lib[lastPlayer]

from itertools import cycle, dropwhile, islice

whoseMove = lambda last, win: next(islice(dropwhile(last.__eq__, cycle(('black', 'white'))), win, win + 1))


def whoseMove(lastPlayer, win):
    return {
        'black': ['white', 'black'],
        'white': ['black', 'white']
        }.get(lastPlayer)[win]

def whoseMove(lastPlayer, win):
    if win:
        return lastPlayer
    else:
        if lastPlayer == 'black':
            return 'white'
        else:
            return 'black'

def whoseMove(p, win):
    return p if win else ['white', 'black'][p == 'white']

def whoseMove(lastPlayer, win):
    return {'white': 'black', 'black': 'white'}.get(lastPlayer) if not win else lastPlayer

def whoseMove(lastPlayer, win):
    players = 'blackwhite'
    if win:
        result = lastPlayer
    else:
        result = players.replace(lastPlayer, '')
    return result

from itertools import cycle, dropwhile, islice

def whoseMove(lastPlayer, win):
      order = dropwhile(lastPlayer.__eq__, cycle(('black', 'white')))
      return win and lastPlayer or next(order)

def whoseMove(lastPlayer, win):
    return ('white', 'black')[win ^ lastPlayer.startswith('w')] 

def whoseMove(x,y,b='black',w='white'):
    return x if y else w if x == b else b

def whoseMove(lastPlayer, win):
    return ['black','white'][not win] if lastPlayer == 'black' else ['black','white'][win]

def whoseMove(lastPlayer, win):
    return 'black' if ((lastPlayer == 'black' and win) or (lastPlayer == 'white' and not win)) else 'white'

def whoseMove(lastPlayer, win):
    return lastPlayer if win else [n for n in ['black', 'white'] if n != lastPlayer][0]

def whoseMove(lastPlayer, win):
    d = {
        'black' : 'white',
        'white' : 'black'
    }
    return lastPlayer if win else d.get(lastPlayer)

whoseMove = lambda l,w:'bwlhaictke'[(l[0]=='b')!=w::2]

def whoseMove(p, win):
    return 'white' if (p == 'white' and win) or (p == 'black' and not win) else 'black'

def whoseMove(lastPlayer, win):
    if lastPlayer == 'white' and not(win):
        return 'black'
    elif lastPlayer == 'black' and win:
        return 'black'
    else:
        return 'white'

opposite = {
    'white': 'black',
    'black': 'white'
}

def whoseMove(last, win):
    return last if win else opposite[last]

def whoseMove(lp, win):
    if win:
        return lp
    else:
        return [i for i in ['black','white'] if i not in lp][0]
    


def whoseMove(lastPlayer, win):
    if lastPlayer == 'white':
        opp = 'black'
    else:
        opp = 'white'
    
    return lastPlayer if win else opp

def whoseMove(lastPlayer, win):
    l=['black','white']
    return lastPlayer if win else l[l.index(lastPlayer)-1]

def whoseMove(last_player, win):
    other = 'black' if last_player == 'white' else 'white'
    return last_player if win else other

def whoseMove(lastPlayer, win):
    return "black" if lastPlayer == "white" and not win else 'white' if lastPlayer == "black" and not win else lastPlayer


def whoseMove(last, win):
    return last if win else {"white": "black", "black": "white"}[last]

def whoseMove(lastPlayer, win):
    if win==False  : return{'white':'black', 'black':'white'}[lastPlayer]
    if win==True   : return lastPlayer 

def whoseMove(lastPlayer, win):
    return lastPlayer if win else list({'black', 'white'} - {lastPlayer})[0]

whoseMove = lambda lp, win: {True: 'white', False:'black'}[(lp == 'black')^win]

def whoseMove(lastPlayer, win):
    d={'black':'white','white':'black'}
    if win: return lastPlayer
    else: return d[lastPlayer]

def whoseMove(lastPlayer, win):
    if lastPlayer == "black":
        return lastPlayer if  win else 'white'
    else:
        return 'white' if  win else 'black'

def whoseMove(lastPlayer, win):
    if win:
        return lastPlayer
    elif not win:
        if lastPlayer == 'black':
            return 'white'
        else:
            return 'black'

def whoseMove(p, n):
    return p if n else 'black' if p=='white' else 'white'

def whoseMove(lastPlayer, win):
    lose = {"white": "black", "black": "white"}
    return lastPlayer if win else lose.get(lastPlayer)

def whoseMove(lp, abool):
    if lp == "black":
        if abool== True:
            ansr = "black"
        else:
            ansr = "white"
    if lp == "white":
        if abool == True:
            ansr = "white"
        else:
            ansr = "black"
    return ansr

def whoseMove(lastPlayer, win):
    a = ['black','white']
    return lastPlayer if win else a[(a.index(lastPlayer)+1)%2]

def whoseMove(lastPlayer, win):
    if win == True:
        return lastPlayer
    elif lastPlayer == 'white' and win == False:
        return 'black'
    elif lastPlayer == 'black' and win == False:
        return 'white'

def whoseMove(lp, w):
    if lp=='white' and w==True or lp=='black' and w==False:
        return 'white'
    return 'black'

def whoseMove(lastPlayer, win):
    players = ['black', 'white']
    return lastPlayer if win else players[(players.index(lastPlayer) + 1) % 2]

def whoseMove(lastPlayer, win):
    player = {'white': 'black',
             'black': 'white'}
    return lastPlayer if win else player[lastPlayer]

def whoseMove(lastPlayer, win):
    if lastPlayer == 'black':
        nextPlayer = 'white'
    else:
        nextPlayer = 'black'
    if win:
        return lastPlayer
    else:
        return nextPlayer

whoseMove=lambda l,w:l if w else "".join([chr(x^y) for x,y in zip([21,4,8,23,14],l.encode())])

whoseMove=lambda l,w:['black','white'][((l[0]=='w')+1-w)%2]

def whoseMove(last, win):
    if win==True:
        return last
    else:
        return "black" if last=="white" else "white"

def whoseMove(lastPlayer, win):
    if lastPlayer=='black':
        return 'black' if win == True else 'white'
    else:
        return 'white' if win == True else 'black'

def whoseMove(lastPlayer, win):
    if win and lastPlayer=="black":
        return "black"
    elif win and lastPlayer=="white":
        return "white"
    elif not win and lastPlayer=="black":
        return "white"
    else:
        return "black"

def whoseMove(lastPlayer, win):
    p = {"black" : "white", "white" : "black"}
    if win :
        return lastPlayer
    else :
        return p[lastPlayer]

def whoseMove(lastPlayer, win):
    winlose = ['black', 'white']
    winlose.remove(lastPlayer)
    return lastPlayer*win + winlose[0]* (not win)

def whoseMove(lastPlayer, win):
    if lastPlayer=="black" and win or lastPlayer=="white" and not(win):
        return "black"
    if lastPlayer=="white" and win or lastPlayer=="black" and not(win):
        return "white"


def whoseMove(lastPlayer, win):
    if win == True:
        return lastPlayer
    
    if lastPlayer == "white":
        return "black"
    
    else:
        return "white"

def whoseMove(lastPlayer, win):
    if lastPlayer == 'black' and win == False or lastPlayer =='white' and win == True : return 'white'
    elif lastPlayer == 'white' and win == False or lastPlayer =='black' and win == True: return 'black'

def whoseMove(lastPlayer, win):
    if win == True:
        return lastPlayer
    if win == False:
        if lastPlayer == 'black':
            return "white" 
        else:
            return "black"
    


def whoseMove(lastPlayer, win):
    if lastPlayer=='white' and win:
        return 'white'
    elif lastPlayer=='white' and not win:
        return 'black'
    elif lastPlayer=='black' and win:
        return 'black'
    else:
        return 'white'

def whoseMove(lastPlayer, win):
    if win is False:
        if lastPlayer=='black':
            return 'white'
        return 'black'
    if win is True:
        if lastPlayer=='black':
            return 'black'
        return 'white'

def whoseMove(lastPlayer, win):
    if win != True:
        if lastPlayer == 'black':
            return 'white'
        else:
            return 'black'
    else:
        return lastPlayer

def whoseMove(lastPlayer, win):
    if win == True:
        return lastPlayer
    else:
        return "black" if lastPlayer == "white" and win == False else "white"

def whoseMove(lastPlayer, win):
    pls = ['black', 'white']
    return lastPlayer if win else pls[pls.index(lastPlayer)-1]

def whoseMove(lastPlayer, win):
    if lastPlayer == 'black' and win:
        return 'black'
    if lastPlayer == 'black' and win == False:
        return 'white'
    if lastPlayer == 'white' and win:
        return 'white'
    if lastPlayer == 'white' and win == False:
        return 'black'

def whoseMove(last_player, win):
    return last_player if win else {"white": "black"}.get(last_player, "white")

def whoseMove(l, w):
    return 'white' if (l=='black' and not w) or ((l=='white' and w)) else 'black'

def whoseMove(lastPlayer, win):
    if lastPlayer == 'black' and win is False:
        return 'white'
    elif lastPlayer == 'black' and win is True:
        return'black'
    elif lastPlayer == 'white' and win is False:
        return'black'
    elif lastPlayer == 'white' and win is True:
        return'white'

def whoseMove(lastPlayer, win):
    other = ""
    if lastPlayer == "black":
        other = "white"
    else:
        other = "black"
    if win:
       return lastPlayer
    return other
 
        
        
    # Your Move...


def whoseMove(lastPlayer, win):
    l = lastPlayer
    w = win
    
    if l == 'white' and w == False:
        return 'black'
    
    if l == 'white' and w == True:
        return 'white'
    
    if l == 'black' and w == True:
        return 'black'
    
    if l == 'black' and w == False:
        return 'white'

def whoseMove(lastPlayer, win):
    if win == False and lastPlayer == "black":
        return "white"
    elif win == False and lastPlayer == "white":
        return "black"
    return lastPlayer

def whoseMove(lastPlayer, win):
    print(lastPlayer, win)
    return lastPlayer if win else 'white' * (lastPlayer != 'white') + 'black' * (lastPlayer != 'black')

def whoseMove(lastPlayer, win):
    loser = {"white": "black", "black":"white"}
    winer = {"black": "black", "white":"white"}
    
    if win:
        return winer[lastPlayer]
    else:
        return loser[lastPlayer] 

def whoseMove(lastPlayer, win):
    if win:
        return lastPlayer
    else:
        return ('black','white') [lastPlayer == 'black']

def whoseMove(lastPlayer, win):
    players = ('black', 'white', 'black')
    return players[players.index(lastPlayer) + (not win)]

def whoseMove(lastPlayer, win):
    temp = {'black':'white', 'white':'black'}
    if win == True:
        return lastPlayer
    else:
        return temp[lastPlayer]

def whoseMove(lastPlayer, win):
    if lastPlayer == "white" and win is True:
        return "white"
    if lastPlayer == "black" and win is True:
        return "black"
    if lastPlayer == "white" and win is False:
        return "black"
    if lastPlayer == "black" and win is False:
        return "white"


def whoseMove(lastPlayer, win):
    return "white" if ("white" == lastPlayer and win == True) or (lastPlayer == "black" and win == False) else "black"

def whoseMove(lastPlayer, win):
    if lastPlayer == 'black':
        return 'white' if win == False else 'black'
    elif lastPlayer == 'white':
        return 'black' if win == False else 'white'

def whoseMove(lastPlayer, win):
    if lastPlayer=='white'and win:
        return "white"
    elif lastPlayer=='black' and not win:
        return 'white'
    elif lastPlayer=='white' and not win:
        return 'black'
    elif lastPlayer=='black' and win:
        return 'black'

players = ['white', 'black']
def whoseMove(lastPlayer, win):
    return players[(players.index(lastPlayer) + (not win)) % len(players)]

opponents = {'black': 'white', 'white': 'black'}

def whoseMove(last_player, win):
    return last_player if win else opponents[last_player]

def whoseMove(lastPlayer, win):
    players=['white', 'black']
    if win: return lastPlayer
    else:
      players.remove(lastPlayer)
      return players[0]

whoseMove = lambda last_player, win: ('black', 'white', 'black')[('black', 'white').index(last_player) + (not win)]

def whoseMove(lastPlayer, win):
    voc = {'black':'white','white':'black'}
    if win:
        return lastPlayer
    else:
        return voc[lastPlayer]

def whoseMove(lastPlayer, win):
    if win and lastPlayer == 'black': return 'black'
    if not(win) and lastPlayer == 'white': return 'black'
    return 'white'


def whoseMove(lastPlayer, win):
    if lastPlayer == "white":
        other_player = "black"
    else:
        other_player = "white"
    return lastPlayer if win is True else other_player

def whoseMove(lastPlayer, win):
    if win==True :
       return lastPlayer
    if win==False :
       if lastPlayer=="black":
          return "white"
       return "black"

# Without logical operators
def whoseMove(lastPlayer, win):
    return {("black", False): "white",
            ("black", True): "black",
            ("white", False): "black",
            ("white", True): "white",}[(lastPlayer, win)]

def whoseMove(lastPlayer, win):
    return {("black", False): "white",
            ("black", True): "black",
            ("white", False): "black",
            ("white", True): "white",}[(lastPlayer, win)]