MathSpeeder - Firing neurons and nimbling fingers
Alright, it’s been kinda boring lately… so I’ve decided to whip up a picker-upper that will rejuvenate your brain and excite you again. You’ll be churning out flawless code in no time after this.
Enter the MathSpeeder.
MathSpeeder is a console program that fires a series of math questions. Your job is to answer all of them correctly. Oh yeah, you’ll be timed too. Ain’t that cool? Here’s the source code:
const int cnNumberOfQuestions = 10; string response = string.Empty; Console.WriteLine("MathSpeeder - Firing neurons and nimbling fingers"); Console.WriteLine("There are {0} math questions", cnNumberOfQuestions); Console.Write("Ready to play (y/n)? "); response = Console.ReadLine().ToLower(); Console.WriteLine(); if (response.Equals("y")) { int operand1, operand2, result, answer; int score; Random rand = new Random(); score = 0; DateTime start, end; start = DateTime.Now; int i; for (i = 0; i < cnNumberOfQuestions; ++i) { operand1 = rand.Next(1000); operand2 = rand.Next(1000); result = operand1 + operand2; response = string.Format("Q{0}", i + 1).PadLeft(3); Console.Write("{0}: {1} + {2} = ", response, operand1, operand2); response = Console.ReadLine().Trim(); try { answer = Convert.ToInt32(response); if (answer == result) { ++score; Console.WriteLine(" Correct!\n"); } else { Console.WriteLine(" Wrong!\n"); } } catch { Console.WriteLine(" Wrong!\n"); } } end = DateTime.Now; TimeSpan ts = end - start; Console.WriteLine("You got {0} correct answers out of {1} questions", score, cnNumberOfQuestions); Console.WriteLine("Total time taken: {0,0:f2} seconds", ts.TotalSeconds); Console.WriteLine("Average time per question: {0,0:f2} seconds", ts.TotalSeconds / (double)cnNumberOfQuestions); } else { Console.WriteLine("Challenge the MathSpeeder next time then!"); } Console.WriteLine(); Console.WriteLine("End of program"); Console.ReadLine();
Get the program if you’re too lazy to compile the source code. Needs .NET Framework 2.0.
Here’s my result

I must be losing my edge… over 5 seconds per question?
So what’s your score?
Comments
One Response to “MathSpeeder - Firing neurons and nimbling fingers”
Leave a Reply












[...] This is the math puzzle?! Still, in an action game, any kind of math puzzle is probably fatal. I can fumble on simple additions too. Guess I need to practise more. [...]