# How can I use AnyDice to get the odds of a specific number sequence from rolling 3d10 and dropping the lowest die?

I'm not very experienced with the program, or programming in general, and so I'm stuck. I managed to figure out how to get the probability of different sums of highest 2 of 3d10:

output [highest 2 of 3d10]


And from another post I also found a way to calculate the probability of a certain combination of n numbers from n dice:

function: compare A:s and B:s {
result: A = B
}
output [compare 2d10 and {10, 1}]


What I'm ultimately looking for is something like:

function: compare A:s and B:s {
result: A = B
}
output [compare highest 2 of 3d10 and {10, 1}]


I'm wondering if anyone knows how to do this and is willing to help.

• Welcome to RPG.SE! In something like Roll20 I think it'd be written "3d10k2"; "3k2 d10" seems a little confusing. The title might be clearer if you just phrase it plainly as you did in the parenthetical: "a specific number sequence from rolling 3d10 and dropping the lowest die".
– V2Blast
Nov 26, 2018 at 14:35
• Just to clarify: you're looking to get the probability of rolling an exact sum with the highest two of 3d10? That would just be "output [highest 2 of 3d10]" and set the result to show "Normal". Nov 26, 2018 at 19:34

function: compare highest N:n of ROLL:s and SEQ:s {
loop I over {1..N} {
if I@ROLL != I@SEQ { result: 0 }
}
result: 1
}


This function just compares the first N elements of the sequences ROLL and SEQ one by one. (If the sequences are sorted in descending numerical order, like AnyDice sorts dice rolls by default, those will be the N highest elements.) If any of them are different, it stops and returns 0; if they all match, it returns 1.

When a dice pool is passed as one (or even both) of the parameters to this function, AnyDice automatically calls the function for each of the possible sequences of dice produced by the roll(s) and collects the results into a biased die representing the probability of the function returning each of its possible result values.

The key thing to realize here is that, when passing a dice pool into a function expecting a sequence like this, AnyDice doesn't really provide any practical way to get the individual sequences of rolled dice out of the function. All we can get out is a single biased die. This means that, whatever manipulation we want to do with the sequences themselves, we'll have to do inside the function.

Ps. Alternatively, I could've used the highest NUMBER of sequence SEQUENCE function from this answer, and rewritten the function above simply as:

function: compare highest N:n of ROLL:s and SEQ:s {
result: [highest N of sequence ROLL] = [highest N of sequence SEQ]
}


But, besides requiring another custom function as a helper, this version is also probably somewhat less efficient, since it has to loop over both input sequences to make partial copies of them. The first version above does the same thing with just a single loop and no sequence copying.