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.
def mmr(party: bool, win: bool) -> int:
if party and win:
return 20
elif party and not win:
return -20
elif not party and win:
return 30
else:
return -30
import codewars_test as test
import solution
@test.describe("Test Cases")
def test_group():
@test.it("party win")
def test_case():
party = True
win = True
result = solution.mmr(party, win)
test.assert_equals(result, 20)
@test.it("party loss")
def test_case():
party = True
win = False
result = solution.mmr(party, win)
test.assert_equals(result, -20)
@test.it("solo win")
def test_case():
party = False
win = True
result = solution.mmr(party, win)
test.assert_equals(result, 30)
@test.it("solo loss")
def test_case():
party = False
win = False
result = solution.mmr(party, win)
test.assert_equals(result, -30)