Ad
Code
Diff
  • mmr=lambda p,w:(-1)**(w==0)*(30-10*p)
    • mmr=lambda p,w:pow((-1),(not w))*(30-10*p)
    • mmr=lambda p,w:(-1)**(w==0)*(30-10*p)

In the game of dota2 you can either play in two modes: solo (alone) or in a party (with a group of 2+ players). The outcome of these games is either a win or a loss. You gain or lose MMR (matchmaking rating) accordingly.

If you win a dota2 game while in a party, you gain 20 MMR. You lose 20 MMR if you lose the game.

However, if you win a dota2 game while playing solo then you gain 30 MMR and you lose 30 MMR if you lose.

This is because winning with your friends is considered more difficult.

Write a method that will determine the mmr you would get based on the outcome of the game and the type of mode you are playing.

Code
Diff
  • def mmr(party: bool, win: bool) -> int:
        if party:
            if win:
                return 20
            return -20
        if win:
            return 30
        return -30
    • def mmr(party: bool, win: bool) -> int:
    • if party and win:
    • return 20
    • elif party and not win:
    • if party:
    • if win:
    • return 20
    • return -20
    • elif not party and win:
    • if win:
    • return 30
    • else:
    • return -30
    • return -30