# how to calculate the odds of 5d6 higher than 1d10?

In anydice or troll, how can we calculate the odds of rolling 5d6 and counting the successes against 1d10? Successes are every result in each six-sided die equal or higher than the d10 result.

This means that, if the d10 rolls 7, 8, 9, or 10, you always have zero successes, and if it rolls a 1, you always have 5.

I've tried [count {1..d10} in 5d6], but anydice says sequence must end with a number. I've tried 5d6>1d10, but obviously anydice takes 5d6 as the sum of the dice. Maybe it can be done with a custom function, but that seems beyond my skills...

• Welcome to RPG.SE! Take the tour and visit the help center if you need any guidance about posting questions and answers! How do you count when the 1d10 and one 1d6 roll are equal? Success or failure? Feb 27 '21 at 10:26

## You need to cast your dice to a sequence

The trick for dealing with a roll of dice as individual rolls (and not their sum) is to cast it into a sequence. For this, we use a function and specify our dice parameter as a sequence (appending :s). Once we have it as a sequence, we can compare each value to a number. That will give the number of elements in the sequence for which the comparison is true.

function: number of A:s greater or eq than T:n {
result: A >= T
}

output [number of 5d6 greater or eq than 1d10]

• Actually, in this case there's a way to do it without using a sequence parameter. But the method you describe is indeed very powerful and useful in cases where faster methods won't work, so have a +1. Feb 28 '21 at 3:17
• Nice. Thank you! Mar 1 '21 at 7:34
function: test T:n {
X: d6 >= T
result: 5dX
}
output [test d10]


The first trick used here is that, when a die (here, a d10) is passed to a function expecting a number (i.e. as a parameter tagged with :n), AnyDice will automatically call the function for every possible sum of the roll and calculate a weighted average of the results. Thus, inside the function the roll is effectively "frozen" and can be treated as a fixed number.

Next, I use the expression d6 >= T to obtain a distribution that equals 1 with probability $$\(7-T) \mathbin/ 6\$$ (i.e. the probability of rolling at least T on a d6) and 0 otherwise, and save it as a custom die in the variable X. And then I roll 5 of these custom dice to get the number of rolls exceeding T on 5d6 and return it.

Of course, if you want to make the function more flexible, you could also pass the die to be rolled and/or the number of dice in the pool as additional parameters to it.

• Yeah. Well exposed. Thanks! Mar 1 '21 at 7:34

This should work...

function: csuccess roll ROLL:s with target TARGET:n {
if TARGET < 7 {
result: [count {TARGET..6} in ROLL]
}
else {
result: 0
}
}

output [csuccess roll 5d6 with target 1d10]


For a better understanding of what this is doing, this is a less efficient method of the exact same solution:

function: csuccess roll ROLL:s with target TARGET:n {
NUMONES: [count {1} in ROLL]
NUMTWOS: [count {2} in ROLL]
NUMTHREES: [count {3} in ROLL]
NUMFOURS: [count {4} in ROLL]
NUMFIVES: [count {5} in ROLL]
NUMSIXES: [count {6} in ROLL]

if TARGET = 1 {
result: NUMONES+NUMTWOS+NUMTHREES+NUMFOURS+NUMFIVES+NUMSIXES
}
if TARGET = 2 {
result: NUMTWOS+NUMTHREES+NUMFOURS+NUMFIVES+NUMSIXES
}
if TARGET = 3 {
result: NUMTHREES+NUMFOURS+NUMFIVES+NUMSIXES
}
if TARGET = 4 {
result: NUMFOURS+NUMFIVES+NUMSIXES
}
if TARGET = 5 {
result: NUMFIVES+NUMSIXES
}
if TARGET = 6 {
result: NUMSIXES
}
result: 0
}

output [csuccess roll 5d6 with target 1d10]

• It's strange that there are more odds of getting 5 successes than 1,2,3 or 4.... And how getting 1,2,3 or 4 sucesses are nearly equal... P.S. I'm not the one who downvoted. On the contrary, thanks a lot for trying to help! Feb 27 '21 at 17:10
• @DaniCano That is correct, though. There is a 100% chance of rolling 5 successes if a 1 is rolled. There is a 0% chance of rolling 1,2,3 or 4 successes if a 1 is rolled. This immediately adds +0.1 to the probability of rolling a 5 (because there is a 0.1 chance that you will roll a 1 on 1d10). Feb 27 '21 at 17:15
• Yeah, you're right... What if we assume the zero on the d10 is zero and not 10? Feb 27 '21 at 17:19
• Then, in my first solution, change 'output [csuccess roll 5d6 with success 1d10]' to 'output [csuccess roll 5d6 with success d{0..9}]' Feb 27 '21 at 17:21
• @InterstellarProbe is there a reason your function is casting the TARGET parameter as a sequence (:s) rather than a number (:n)? (When only rolling one die to determine the target number it works either way, anyway.) Feb 27 '21 at 18:23