Evaluate a Dice 10,000 roll

05AB1E, 34 31 30 bytes

7G¹N¢O3‰N*2LRN1Q+°*X5‚Nå_i¨}OO

Explanation

7G                                  # for N in 1..6
  ¹N¢O                              # count number of occurrences of N in input
      3‰                            # divmod 3
        N*                          # multiply by N
          2LRN1Q+°*                 # multiply by 10, 100 or 1000
                   X5‚Nå_i¨}        # if N is not 1 or 5, scrap the singles
                            OO      # sum all triple and single scores so far
                                    # implicitly display total sum

Try it online


Python 2, 152 148 125 bytes

Pretty simple solution. Can be golfed more. L.count is a bit long, but I couldn't remove the first call because L is updated.

def f(L):s=n=0;exec"n+=1\nwhile L.count(n)>2:s+=[n*100,1e3][n<2];exec'L.remove(n);'*3\n"*6;C=L.count;print s+100*C(1)+50*C(5)

Try it online - (all test cases)

Ungolfed:

def f(L,s=0):
    L.sort()
    for n in range(1,7):
        while L.count(n)>2:
            s+=n*100*((n<2)*9+1) # multiply by 10 if n==1
            i=L.index(n)
            L=L[:i]+L[i+3:]
    s+=100*L.count(1)+50*L.count(5)
    print s

Some golf credit to @Copper, using some tips from his code


PowerShell v2+ v3+, 147 144 137 133 bytes

$n=$args[0]|sort;while($n){if(($x=$n[0])-eq$n[2]){$s+=100*$x+900*($x-eq1);$a,$b,$n=$n}else{$s+=50*($x-in1,5)+50*($x-eq1)}$a,$n=$n};$s

Crossed out 144 looks kinda like 144?

Takes input $args[0] and sorts it, stores it into $n. Then, while there are still elements left, we evaluate an if/else.

If the first element (temp stored into $x to save some bytes) matches the third element, we have a triple. Add onto the $sum the result of some multiplication 100*$x plus a Boolean-based 900 only if $x is -equal to 1. This gets us the requisite 1000 for three ones. Then, peel off the first two elements into $a, and $b, and the remaining into $n -- removing the third element of the triple is handled later.

Otherwise, we don't have a triple, so add on to $sum the result of another Boolean-based addition. We add 50 if $x is either 1 or 5, then add on another 50 if it's -equal to 1. This section now requires v3+ for the -in operator.

In either case, we still have an element yet to remove, so peel off the first element into $a and leave the remaining in $n.

Finally, once the loop is done, place $s on the pipeline. Output is an implicit Write-Output at the end of execution.

Test cases

PS C:\Tools\Scripts\golfing> (1,2,3,4,5,6),(1,1,1,2,3,5),(1,1,1,1,1,1),(2,2,2,2,2,2),(6,6,1,5,5,6),(2,3,4,6,2,4),(1,5,1,5,1,5),(5,5,5,5,2,3),(1,1,1,1,1,5),(3,3,4,4,3,4)|%{($_-join',')+" -> "+(.\evaluate-dice-1000.ps1 $_)}
1,2,3,4,5,6 -> 150
1,1,1,2,3,5 -> 1050
1,1,1,1,1,1 -> 2000
2,2,2,2,2,2 -> 400
6,6,1,5,5,6 -> 800
2,3,4,6,2,4 -> 0
1,5,1,5,1,5 -> 1500
5,5,5,5,2,3 -> 550
1,1,1,1,1,5 -> 1250
3,3,4,4,3,4 -> 700

Tags:

Code Golf

Game