Nd6, keep highest, +1 for every other 6

Nd6, keep highest, +1 for every other 6

Return to topic list

Mon Aug 20 12:40:55 2018   by   Enrico Magnani
I'm really sorry, I didn't want to bother but it seems I can't wrap my head around the problem.

* I have a pool of N d6.
* I want to keep only the highest die result.
* If the highset is 6 and there are other 6 as well, every other 6 count as +1.


Pool is 5d6, and I roll:
3, 6, 2, 6, 6

Output should be 8.

I can get the highest value out of a pool of d6, but it's the second part that eludes me.
Mon Aug 20 16:20:20 2018   by   Torben
You can do it this way:

1. Get the collection M of maximal values.
2. If M consists of 6s, add the number of values in M to 5.
3. Otherwise, take any value from M

In Troll, this is written as

M := maximal 5d6;
if 6=M then 5 + count M else choose M

where you change the 5 to other values for different pool sizes.
Tue Aug 21 08:49:50 2018   by   Enrico Magnani
Thank you very much for your help!

I was thinking of something along those lines but I couldn't figure out how to write it: maximal, I'll try to remember that!

Return to topic list

New message:
Posted by:

Type the values of the dice shown below:

Return to topic list