Not sure how to tackle this mathematically, but it shouldn't be too difficult to program a brute force search for the solution with a smallish N. And you can use random sampling if N gets too large.

For N = 20 and A = 5, my brute force search program takes ~20 seconds and gives

Code: Select all

`75.0129699707 percent chance of 0 sequences of 5 heads`

22.8675842285 percent chance of 1 sequences of 5 heads

2.06680297852 percent chance of 2 sequences of 5 heads

0.052547454834 percent chance of 3 sequences of 5 heads

9.53674316406e-05 percent chance of 4 sequences of 5 heads

For N = 20 and A = 5, a sample size of 100,000, and a run time of ~6 seconds, my random sampling program gives

Code: Select all

`75.033 percent chance of 0 sequences of 5 heads`

22.837 percent chance of 1 sequences of 5 heads

2.084 percent chance of 2 sequences of 5 heads

0.046 percent chance of 3 sequences of 5 heads

0.0 percent chance of 4 sequences of 5 heads

Which is pretty close.

I assumed that 6 A's count as a single sequence but 10 A's count as two sequences.

If you're looking for a mathematical answer, you can obviously ignore this post (unless you want to double-check your formulas if you obtain any). If you just want an answer, I can post the source code as well (though it's not difficult to figure out).