[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 = $numerator/choose($total,$smgroup);
$answer = $numerator;
$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 />
<numericalresponse answer="$answer" format="5F">
<responseparam type="tolerance" default="0.00001" name="tol" description="Numerical Tolerance" />
<responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures" />
<textline readonly="no" />
</numericalresponse>
</problem>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20120326/91f12474/attachment.html>
More information about the LON-CAPA-users
mailing list