Stats are really not my cup of tea. I have a problem with “4-Ultimate test” (and also test 5 but I would at least understand what is wrong with this one)
I tried to stick as much as possible to the concept of taking balls out of the bag.
I think I got a decent algorithm but I might be totally wrong.

Test 4-Ultimate test
inputs:
n=30 total nb of balls
w=10 nb of white balls
s=10 total nb of balls extracted
k=5 nb of white balls to be extracted

I get the following result

P(A)= 10 / 30 (white ball)
x 9 / 29 (white ball)
x 8 / 28 (white ball)
x 7 / 27 (white ball)
x 6 / 26 (white ball)
x 20 / 25 (black ball)
x 19 / 24 (black ball)
x 18 / 23 (black ball)
x 17 / 22 (black ball)
x 16 / 21 (black ball)
P(A)= 5168 / 10015005
P(!A)= 10009837 / 10015005 result: 5168:10009837 expected: 62016:414889

I don’t see what is wrong: is it my fraction simplification or the way I compute the stats ?
Any help will be greatly appreciated !

I use javascript,
I only do the multiply on the numerator and denominator;
Then i m looking for the largest common divider and divide all…
I m not sure to lose precision using multiply… but you may be right

I have success on all test cases – so efficiency is now OK. I fail on validator 2.
As far as I can tell, I’ve dealt with all divide by zero cases so I don’t think I’m generating an error.
Would appreciate some guidance on where to look/what to improve.
Thanks!