View Single Post
Old 12-04-2009, 06:36 PM  
goldfish
Confirmed User
 
goldfish's Avatar
 
Join Date: Jan 2009
Location: Somewhere east of the Mississippi
Posts: 723
// 50 questions
// 4 random answers

// 60%+ correct = pass
// 30 questions correctly out of 30 = 60%

$questions = _createTest(50,4);
$answers = _answerQuestions(50,4);
$correct_score = _correctTest($questions, $answers);
$passed = 0;


$count = 1;
while ($passed <= 1) {
echo "Taking test #" . $count. "\n";

$questions = _createTest(50,4);
$answers = _answerQuestions(50,4);
$correct_score = _correctTest($questions, $answers);

echo "You're correct answers on test #" . $count . "was " . $correct_score . ".\n";
if ($correct_score >= 30) {
"You Passed the test on the $count try"; exit;
} else {
"You failed\n Retaking test again..."; $count = $count + 1;
}
$count = $count + 1;
}
exit;

function _createTest($questions, $choices) {

$question_array = array();
for ($i=1; $i<=$questions; $i++) {
$question_array[] = rand(1,$choices);
}

return $question_array;

}

function _answerQuestions($answers, $choices) {

$answer_array = array();
for ($i=1; $i<=$answers; $i++) {
$answer_array[] = rand(1,$choices);
}

return $answer_array;
exit;
}

function _correctTest($questions, $answers) {

$theanswers = $answers;
$i = 0;
$correct = 0;
foreach ($questions as $solution) {
//echo "Correct Answer: $solution | Your Answer: $theanswers[$i]\n";
if ($solution == $answers[$i]) { $correct = $correct + 1; }
$i = $i + 1;
}

return $correct;

}

i passed it on the first run in 877,000 test tries 8:01
2nd run as at 2 million mart and still not passed 8:01
out of 15 questions, if you random pick you average about 15 correct and need 30 correct to score %60


yeah, I didn't write this!!
__________________
ICQ: 566990329

"There is no rest for the wicked... and porn purveyors!

Last edited by goldfish; 12-04-2009 at 06:41 PM..
goldfish is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote