Mexen1 is a game of dice played by 2 people. Each roll consists of 2 dice. The game mostly consists of bluffing about your dice, but here we’re only focussing on the scoring. Contrary to a lot of other dice games, your points don’t just equal the sum of your dice rolls.

Image by Edge2Edge Media on Unsplash.

Image by Edge2Edge Media on Unsplash.

Instead, the scoring works as follows:

Assignment

Create a function mexen(s0, s1, t0, t1) that determines the winner, where s0 and s1 are the rolls of player 1 and t0 and t1 belong to player 2. If player 1 wins, you return "speler 1", if player 2 wins, you return "speler 2" and otherwise you return "gelijkspel" (it’s a tie).

To create this function you first create a helper function, score(worp1, worp2), which determines the score of a single player given 2 rolls.

Take a look at the examples below:

Examples

>>> mexen(1, 2, 1, 3)
speler 1

because

>>> score(1, 2)
1000
>>> score(1, 3)
31
>>> mexen(3, 3, 2, 1)
speler 2

because

>>> score(3, 3)
300
>>> score(2, 1)
1000
>>> mexen(6, 6, 2, 2)
speler 1

because

>>> score(6, 6)
600
>>> score(2, 2)
200
>>> mexen(4, 2, 2, 4)
gelijkspel

because

>>> score(4, 2)
42
>>> score(2, 4)
42

Source

Virginia Tech High School Programming Contest 2014