Bầu cua tôm cá
Description:
This is a coding take on a traditional Vietnamese dice game of chance.
If one die corresponds with a bet, the bettor receives 1x amount as their bet, 2x for two corresponding dice, and 3x for 3 dice. Else the bet is lost.
For instance, if one were to place £3 on fish, and the dealer rolls 2 fish and 1 stag, then the bettor would receive £6 while keeping the £3 they had bet. For simplicity, in this instance one would have a net +6. In this instance, if they had lost the bet, they would receive -3.
Full rules: https://en.wikipedia.org/wiki/B%E1%BA%A7u_cua_c%C3%A1_c%E1%BB%8Dp
The 6 dice sides are representated by string values of the following: "fish", "prawn", "crab", "rooster", "stag", "calabash"
Solution:
Given function rollDice, there are two parameters; dice and bets. Dice is a length 3 string array representing the dice throws for a single round. Bets is a map of maps, maintaining player names-to-dice sides-to-bet amounts.E.g.
rollDice( ["fish", "fish", "stag"],
{
"Billy": {
"fish": 3,
"rooster": 5
},
"Michael": {
"prawn": 10
},
"Lucille": {
"calabash": 3,
"stag": 8
}
}
)
Return a map of participating player names to an integer sum of each players total winnings (or losses)
E.g.
{Billy: 1, Michael: -10, Lucille: 5}
Additional assumptions:
- There are no limits on the number of players
- There are no limits on bet size
- Potentially, zero bets can occur in a round
- Each player can bet on zero-six places
Stats:
Created | Aug 15, 2018 |
Published | Aug 16, 2018 |
Warriors Trained | 93 |
Total Skips | 18 |
Total Code Submissions | 73 |
Total Times Completed | 21 |
JavaScript Completions | 21 |
Total Stars | 1 |
% of votes with a positive feedback rating | 89% of 14 |
Total "Very Satisfied" Votes | 12 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 13 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |