# Help with counting successes with multiple target numbers

I was trying to do an analysis of counting successes using AnyDice, and the basic version of it I got without problems. However, the system I am trying to investigate uses a mix of target numbers for the successes, and that is the part that is being tough to figure out. In short, you roll a pool of d6s and each obstacle has a difficulty like 3 Ob 4 + 1 Ob 5, meaning you need to roll at least three 4s and one 5 to succeed. Other obstacles might be like 4 Ob 4, or 3 Ob 4 + 1 Ob 6, or 3 Ob 4 + 1 Ob 3, etc.

I would be very grateful if somebody can give me some light on how to do this on AnyDice. Thanks.

• Hello and welcome! Take the tour and visit the help center in case you need any guidance in posting on RPG.SE! In 3Ob4 + 1Ob5 you need 3 results greater or equal than 4 and one greater of equal than 5 or exactly three 4s and one 5? Commented Aug 1 at 6:20

If we sort the dice from highest to lowest, and we observed that the player's $$\i\$$th roll (starting from $$\i = 1\$$) rolled $$\x\$$, then we know that all $$\i\$$ rolls up to that point rolled at least $$\x\$$. Therefore, when we have "3 Ob 4 + 1 Ob 5", it is convenient to think of it as the player having to roll at least one 5+, and four total 4+s including that 5+.

With this, we can sort the player's rolls and the obstacle numbers, match them up in pairs much like RISK, and see whether the player won every pair. (Presumably the player automatically fails if they have fewer dice than the obstacle.) We can use the fact that when we send a dice pool into a parameter of type sequence, AnyDice will run the function over all possible sorted sequences that could come out of that pool:

function: compair ROLL:s all ge OB:s {
OB: [sort OB]
if #ROLL < #OB {
result: 0
}
loop I over {1..#OB}{
if I@ROLL < I@OB {
result: 0
}
}
result: 1
}

output [compair 7d6 all ge {5, 4, 4, 4}]