Skip to main content
Saved additional 4 bytes by doubling up on the peeling-off-first-element
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell v2+ v3+, 147 144 137137 133 bytes

$n=$args[0]|sort;while($n){if(($x=$n[0])-eq$n[2]){$s+=100*$x+900*($x-eq1);$a,$b,$c,$n=$n}else{$s+=50*($x-in1,5)+50*($x-eq1);$a}$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 threetwo elements into $a, and $b, $c 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. Then

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

PowerShell v2+ v3+, 147 144 137 bytes

$n=$args[0]|sort;while($n){if(($x=$n[0])-eq$n[2]){$s+=100*$x+900*($x-eq1);$a,$b,$c,$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 three elements into $a, $b, $c and the remaining into $n.

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. Then, peel off the first element 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

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
Saved some bytes by using Boolean logic for addition rather than pseudo-ternaries
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell v2+v2+ v3+, 147 144144 137 bytes

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

Crossed out 144 looks kinda like 144?

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 pseudoBoolean-ternary array lookup based on whetherbased 900 only if $x is -equal to 1, either 100*$x or. This gets us the requisite 1000 for three ones. Then, peel off the first three elements into $a, $b, $c and the remaining into $n.

Otherwise, we don't have a triple, so add on to $sum the result of another pseudoBoolean-ternary that pulls out whether it's abased addition. We add 50 if $x is either 1 or 5 and selects, then add on another 50 if it's -equal to 1. This section now requires v3+ for the number appropriately-in operator. Then, peel off the first element and leave the remaining in $n.

PowerShell v2+, 147 144 bytes

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

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 a pseudo-ternary array lookup based on whether $x is -equal to 1, either 100*$x or 1000. Then, peel off the first three elements into $a, $b, $c and the remaining into $n.

Otherwise, we don't have a triple, so add on to $sum the result of another pseudo-ternary that pulls out whether it's a 1 or 5 and selects the number appropriately. Then, peel off the first element and leave the remaining in $n.

PowerShell v2+ v3+, 147 144 137 bytes

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

Crossed out 144 looks kinda like 144?

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 three elements into $a, $b, $c and the remaining into $n.

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. Then, peel off the first element and leave the remaining in $n.

Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell v2+, 147 144 bytes

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

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 a pseudo-ternary array lookup based on whether $x is -equal to 1, either 100*$x or 1000. Then, peel off the first three elements into $a, $b, $c and the remaining into $n.

Otherwise, we don't have a triple, so add on to $sum the result of another pseudo-ternary that pulls out whether it's a 1 or 5 and selects the number appropriately. Then, peel off the first element 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