SRL Archive - Other Scripts

SCAR Mathematics Quiz!


Daniel

2009-08-11 14:06:20

Mathematics Quiz in SCAR
By Dan's The Man


Simple to set-up, run the script and have fun answering those mathematical questions ;)

Currently supports:
  • Multiplication
  • Division
  • Addition
  • Subtraction
  • Exponent

Sample debug output for 5 questions:
[INDENT]1) Correct! 3 + 3 = 6
2) Wrong… 3 + 5 does not equal 7. 3 + 5 = 8
3) Correct! 3^2 = 9
4) Wrong… 8 / 7 does not equal 0.2. 8 / 7 = 1.14
5) Wrong… 3 + 4 does not equal 8. 3 + 4 = 7
[/INDENT]

(*
Maths Quiz by Dan's The Man (Mayazcherquoi).

Answer the maths questions provided as quick as possible.

Setup lines 12 to 15 :-), run the script and enjoy!
*)

program QuizMaths;

const
QstLimit = 5; //How Many Questions? NOTE: The more questions, the harder they are.
DifLevel = 5; //Difficulty level? 1 = +; 2 = +-; 3 = +-*; 4 = +-*/;
//Max DifLevel is 10. 5 and above uses to the power. The higher the DifLevel from
//5, the harder it is to calculate the answer if it's to the power.
Timing = True; //Time your results?

var
i, dL, i1, i2, dP, tI: Integer;
Ans: Extended;
s, bs: String;
TIA: TExtendedArray;

//Returns the fractional part of the parametre X.
//e.g: X = 1.2, Result := 0.2.
function Frac(const X: Extended): Extended;
begin
Result := X - Int(X);
end;

//Converts parametre X to D decimal places.
function ToDecPla(X: Extended; D: Integer): Extended;
var
n, bX: Extended;
begin
n := Pow(10, d);
bX := x * n;
Result := (Int(bX) + Int(Frac(bX) * 2)) / n;
end;

var
ra: Extended;

begin
ClearDebug;
SetLength(TIA, QstLimit);
dL := DifLevel;
if(dL > 10) then
dL := 10;
if(dL < 1) then
dL := 1;
for i := 1 to QstLimit do
begin
i1 := (RandomRange(1, i + QstLimit - (Random(3)))) + 1;
i2 := (Random(i + QstLimit)) + 1;
case (Random(dL) + 1) of
1:
begin
bS := (IntToStr(i1)) +
' + ' + (IntToStr(i2));
Ans := i1 + i2;
end;
2:
begin
bS := (IntToStr(i1)) +
' - ' + (IntToStr(i2));
Ans := i1 - i2;
end;
3:
begin
bS := (IntToStr(i1)) +
' * ' + (IntToStr(i2));
Ans := i1 * i2;
end;
4:
begin
if(i1 = 0) then
i1 := 1;
bS := (IntToStr(i1)) +
' / ' + (IntToStr(i2));
Ans := i1 / i2;
end;
5..10:
begin
while (i1 > dL) do
i1 := i1 - dL;
while (i2 > dL) do
i2 := i2 - dL;
bS := (IntToStr(i1)) + '^' +
(IntToStr(i2));
Ans := Round(Pow(i1, i2));
end;
end;
if(Timing) then
TIA[i - 1] := GetSystemTime;
s := Readln(bs);
if(Timing) then
TIA[i - 1] := GetSystemTime - TIA[i - 1];
dP := (Length(s)) - (Pos('.', s));
ra := ToDecPla(StrToFloatDef(s, -1234567890), 2);
if(ToDecPla(Ans, 2) = ra) then
Writeln(IntToStr(i) + ') Correct! ' + bS + ' = ' + FloatToStr(ToDecPla(Ans, 2))) else
if(ra = -1234567890) then
Writeln(IntToStr(i) + ') You didn'#39't even attempt to answer ' + bS + '. The answer would'#39've been ' + FloatToStr(ToDecPla(Ans, 2))) else
Writeln(IntToStr(i) + ') Wrong... ' + bS + ' does not equal ' +
FloatToStr(ra) + '. ' + bS + ' = ' + FloatToStr(ToDecPla(Ans, 2)));
if(Timing) then
Writeln('It took you ' + FloatToStr(TIA[i - 1]) + ' milliseconds to answer that question.');
end;
if(Timing) then
begin
Writeln('Your average time to answer those ' + IntToStr(QstLimit) + ' questions was:');
Writeln(' ' + IntToStr(Round(Average(TIA))) + ' milliseconds.');
end;
end.

Enjoy and post your results :D

Laur€ns

2009-08-11 14:17:16

1) You didn't even attempt to answer 4 / 3. The answer would've been 1,33
It took you 2313 milliseconds to answer that question.
2) Correct! 5^4 = 625
It took you 8343 milliseconds to answer that question.
3) Correct! 3 / 6 = 0,5
It took you 3907 milliseconds to answer that question.
4) Correct! 2 + 4 = 6
It took you 1531 milliseconds to answer that question.
5) Correct! 9 + 9 = 18
It took you 1312 milliseconds to answer that question.
Your average time to answer those 5 questions was:
3481 milliseconds.
Successfully executed


Bah @ question 1.

Simtoon

2009-08-11 14:34:35

Your average time to answer those 5 questions was:
291 milliseconds.
Successfully executed

Daniel

2009-08-11 14:47:42

From: Simtoon
Your average time to answer those 5 questions was:
291 milliseconds.
Successfully executed


Care to give the rest of the debug info? :p

Craig`

2009-08-11 15:45:10

Lol I had the easiest questions :P

[php]
1) Correct! 5 + 1 = 6
It took you 1157 milliseconds to answer that question.
2) Correct! 4^2 = 16
It took you 2187 milliseconds to answer that question.
3) Correct! 3 + 8 = 11
It took you 1234 milliseconds to answer that question.
4) Correct! 7 * 2 = 14
It took you 1750 milliseconds to answer that question.
5) Correct! 9 - 10 = -1
It took you 2985 milliseconds to answer that question.
Your average time to answer those 5 questions was:
1863 milliseconds.
Successfully executed
[/php]I could have done them a lot faster but I was doing other stuff also :P

Runescapian321

2009-08-11 16:04:00

From: Mathematics
Lol I had the easiest questions :P

[php]
1) Correct! 5 + 1 = 6
It took you 1157 milliseconds to answer that question.
2) Correct! 4^2 = 16
It took you 2187 milliseconds to answer that question.
3) Correct! 3 + 8 = 11
It took you 1234 milliseconds to answer that question.
4) Correct! 7 * 2 = 14
It took you 1750 milliseconds to answer that question.
5) Correct! 9 - 10 = -1
It took you 2985 milliseconds to answer that question.
Your average time to answer those 5 questions was:
1863 milliseconds.
Successfully executed
[/php]I could have done them a lot faster but I was doing other stuff also :P


+1

1) Correct! 4 - 4 = 0
It took you 1466 milliseconds to answer that question.
2) Correct! 2 * 2 = 4
It took you 1341 milliseconds to answer that question.
3) Correct! 2 + 1 = 3
It took you 1123 milliseconds to answer that question.
4) Correct! 7 * 7 = 49
It took you 2449 milliseconds to answer that question.
5) Correct! 8 + 10 = 18
It took you 1295 milliseconds to answer that question.
Your average time to answer those 5 questions was:
1535 milliseconds.


Nice script :)

Simtoon -

Your average time to answer those 5 questions was:
153 milliseconds.


EDIT: No I did not just take a 5 off the first one :p

Daniel

2009-08-15 15:33:33

From: Mathematics
Lol I had the easiest questions :P

[php]
1) Correct! 5 + 1 = 6
It took you 1157 milliseconds to answer that question.
2) Correct! 4^2 = 16
It took you 2187 milliseconds to answer that question.
3) Correct! 3 + 8 = 11
It took you 1234 milliseconds to answer that question.
4) Correct! 7 * 2 = 14
It took you 1750 milliseconds to answer that question.
5) Correct! 9 - 10 = -1
It took you 2985 milliseconds to answer that question.
Your average time to answer those 5 questions was:
1863 milliseconds.
Successfully executed
[/php]I could have done them a lot faster but I was doing other stuff also :P


Try setting the difficulty level to 10 then ;) (10 is the highest it can go).

caused

2009-08-19 00:18:41

6^9 ???
Dammit . I give up already :'D….

Very cool app though :).
You might want to add a mode for >childs< to practice the small 1x1.
and for >middle-age pupils< the big 10x10(or however thats called in english)..
And for >SRLmembers< huge Exponentiations and sqrt and stuff :'D…

No.. I'm not that smart.

~caused

Ron

2009-08-19 09:02:15


1) Correct! 3 * 2 = 6
It took you 2172 milliseconds to answer that question.
2) Correct! 5^4 = 625
It took you 5547 milliseconds to answer that question.
3) Correct! 2^2 = 4
It took you 1984 milliseconds to answer that question.
4) Correct! 4^2 = 16
It took you 1922 milliseconds to answer that question.
5) Correct! 8 / 5 = 1.6
It took you 10531 milliseconds to answer that question.
Your average time to answer those 5 questions was:
4431 milliseconds.


Nice script, I like your ToDecimalPlace function it's much better than the one I attempted to make. :)

Daniel

2009-08-19 15:03:53

From: Ron
Nice script, I like your ToDecimalPlace function it's much better than the one I attempted to make. :)

You can use it if you want :)

5) Correct! 8 / 5 = 1.6
It took you 10531 milliseconds to answer that question.

Do i smell cheating? xD 10 seconds. Enough time to open up a calculator and enter that :p

Ron

2009-08-19 21:54:09

Actually i did that using long division in my head.

8 / 5 = 1 with 3 remainder, add a decimal point, add a zero, 5 goes into 30 6 times therefore its 1.6. This took me 5 seconds to write and it took me 10 seconds to do cause i was high and distracted by everything. :)

Daniel

2009-08-20 10:29:36

From: Ron
Actually i did that using long division in my head.

8 / 5 = 1 with 3 remainder, add a decimal point, add a zero, 5 goes into 30 6 times therefore its 1.6. This took me 5 seconds to write and it took me 10 seconds to do cause i was high and distracted by everything. :)


Pretty smart :p You just helped me gain some knowledge in Maths :D

Thanks btw <3

Rich

2009-08-24 18:49:26

Out of curiosity, did you get the idea from me? *Look in my siggy - bottom link*

Daniel

2009-08-25 11:51:21

From: R1ch
Out of curiosity, did you get the idea from me? *Look in my siggy - bottom link*


Lol, nup :p Sorry, didn't know one already existed :(

Rich

2009-08-25 14:50:16

No problem. I was just wondering. Anyway, more is better I suppose, isn't it? :p