Skip to content

Commit

Permalink
Prevent point placed with label outside of window
Browse files Browse the repository at this point in the history
The problem generates two random but distinct numbers between 2 and 5.
In order to assure that they are distinct, it increases one of them by
1 if they are equal. This may result in one of the numbers being 6,
which will cause a point on the graph placed on the edge of the graphing
window, with invisible label, which makes it impossible to answer the
problem.

The fix selects the second number repeatedly until the numbers are
distinct.
  • Loading branch information
lahvak committed Sep 7, 2024
1 parent c3853c2 commit 172bbb2
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

$a = random(2,5,1);
$y = random(2,5,1);
if ($y == $a) {$y = $y+1;}
do {$y = random(2,5,1);} until ($y != $a);
$s = random(-1,1,2);
$b = ln($y/$a)/ln(2);
$a = $a*$s;
Expand Down

0 comments on commit 172bbb2

Please sign in to comment.