Probability that a series of dice will roll to a value higher than X I am trying to create a calculator to solve a dice-roll problem in a role playing game that I play. Essentially, various character classes can attack a sleeping dragon with their own series of dice, ex:


*

*An orc might be able swing an axe for 1d32 (one 32 sided dice-roll) damage in one turn

*An elf might shoot two arrows and slingshot in one turn, doing 2d19 + 1d12 damage
If they don't kill the dragon in one turn, it will wake up and instantly kill them.
What I'm trying to find is this:
Given a particular probability threshold $p$, and a series of attack dice $x_1, x_2, \ldots, x_n$, what is the maximum HP the dragon can be at to satisfy $chanceToKillDragon \ge p$?
Example:
My elf rolls for 2d23 + 1d12 damage in one turn. Given that $p=0.50$, he should only attack dragons with $hp \le 31$. If the dragon was at 32 hp, my elf's chance to kill the dragon (roll a 32 or higher) would be 46.22%, which is smaller than the given $p=0.50$, so should not be done. 31 is the highest HP for the kill chance to be >50%.
Anyone have any ideas how I could go about calculating this? Currently I'm using an online dice roll calculator and just repeatedly inputting numbers by trial and error, but I would like to have a direct formula to calculate the number directly.
Any help would be greatly appreciated!
 A: Let $x_i$ denote the number of sides of the $i$-th attack dice used and suppose you use $n$ dices. The damage done solely by dice $i$ is a random variable with uniform distribution on $\{1, \ldots, x_i\}$, i.e., assumes each value on this set with equal probability $1/x_i$. Thus, you have that the maximum damage is $\sum_{i=1}^n x_i$ and the minimum damage is $n$. Any value on the range $R = [n, \sum_{i=1}^n x_i] \cap \mathbb{Z}$ has positive probability. To find out the precise probability of getting $r \in R$, you must sum over all possible combinations of dice that sum $r$.
More precisely, let $X_i$ be the random variable that represents the outcome of dice $i$. Since all dice are independent and uniform on their respective ranges, we have
$$
P[(X_1, \ldots, X_n) = (r_1, \ldots, r_n)] = \prod_{i=1}^n \frac{1}{x_i},
$$
and notice that the right hand side does not depend on the specific values of $r_i$. We have that
\begin{align*}
P\left[ \sum_{i=1}^n X_i = r \right]
&= \sum_{\substack{(r_1, \ldots, r_n);\\ \sum r_i = r}}
  P[(X_1, \ldots, X_n) = (r_1, \ldots, r_n)] \\
&= \left( \prod_{i=1}^n \frac{1}{x_i} \right) \cdot
  \#\left\{(r_1, \ldots, r_n); \sum r_i = r\right\}
\end{align*}
and analogously we have
\begin{align*}
P\left[ \sum_{i=1}^n X_i \geq r \right]
&= \left( \prod_{i=1}^n \frac{1}{x_i} \right) \cdot
  \#\left\{(r_1, \ldots, r_n); \sum r_i \geq r\right\}
\end{align*}
Your problem asks to find the minimum $r(p)$ such that
\begin{align*}
P\left[ \sum_{i=1}^n X_i \geq r \right]
&\geq p.
\end{align*}
By the reasoning above, we can translate this problem into a counting problem. You just need to compute
$$
\# \{ (r_1, \ldots, r_n);\ 1 \le r_i \le x_i, \sum r_i \geq r \}
$$
However, as mentioned in the comments, although you could write a formula for this in terms of binomial numbers I do not think that this formula would be very useful to you. For instance, a similar problem is to show
$$
\# \{ (r_1, \ldots, r_n);\ 0 \le r_i, \sum r_i = r \} = \binom{r+n-1}{r}
$$
and a small variation of it states that
$$
\# \{ (r_1, \ldots, r_n);\ 1 \le r_i, \sum r_i = r \} 
= \# \{ (r_1, \ldots, r_n);\ 0\le r_i, \sum r_i = r - n \} 
=\binom{r-1}{r-n}
$$
Introducing restrictions from above for the $r_i$ and afterwards summing for possible values of $r$ will get messy.
I do not know if your question emphasizes the theoretic point of view or if you are just interested in a practical one. It appears that there are already some sites that do this work for you; if you know how to program, it might be interesting to write one program by yourself to do this computation.
