# [LON-CAPA-users] What happens if a problem runs too long? (choose)

Seema Ali sali at vsb.bc.ca
Tue Mar 27 00:18:39 EDT 2012

```Below, I created a problem, that I think should run fine, but apparently it is running too long.  I don't know why and how does Lon Capa deal with problems that run too long?

Thanks.

<problem>
<script type="loncapa/perl">sub choose{
#  \$n = shift @_;
#  \$r = shift @_;
#  (\$n,\$r) = @_;
\$n = \$_[0];
\$r = \$_[1];
\$nr = \$n-\$r;
return &cas('maxima', "binomial(\$n,\$r)");

}

\$a="";
\$total  = &random(6,8,1)*10;
\$female = &random(30,50,1)+1;
\$male   = \$total - \$female;
\$atmost = &random(3,4,1);
\$smgroup= \$atmost+1;  #just needs to be bigger than \$atmost and smaller than \$female or \$male
\$numerator = 0;

\$denominator = choose(\$total,\$smgroup);

for(\$i=0; \$i<\$atmost; \$i++)
{
\$numerator += choose(\$male,\$i)* choose(\$female,\$smgroup-\$i)/ \$denominator;

}
\$answer = &roundto(\$answer,4);</script><startouttext />A convention is attended by \$total people of whom \$female are women and \$male are men.  If \$smgroup of these people are randomly chosen to receive a door prize, what is the probability that at most \$atmost will be men?
<br />
RUNS LONG AND NEEDS TO BE CHECKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<endouttext />