Beta

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
Fundamentals
Arrays
Algorithms

Stats:

CreatedAug 15, 2018
PublishedAug 16, 2018
Warriors Trained93
Total Skips18
Total Code Submissions73
Total Times Completed21
JavaScript Completions21
Total Stars1
% of votes with a positive feedback rating89% of 14
Total "Very Satisfied" Votes12
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Huongg Avatar
Ad