I present to you a test! Your test is to test. The test is to test the testee with tests a tester gives you, in the shortest amount of code. Specifically, you will give a multiple choice test that you have recieved as input.
In this challenge, you must take an input like this:
1. Our site is called Programming Puzzles & Code ________.
A: Debugging
*B: Golf
C: Hockey
D: Programming
2. What is the *most* popular tag on our site?
A: [debug]
B: [program]
*C: [code-golf]
D: [number]
E: [c++]
3. We are part of the ________ Exchange network.
*A: Stack
B: Code
C: Programmer
D: Hockey
4. Is this the first question?
A: Yes
*B: No
5. Is this the last question?
*A: Yes
B: No
And here is an example of the test being taken:
1. Our site is called Programming Puzzles & Code ________.
A: Debugging
B: Golf
C: Hockey
D: Programming
answer: B
correct!
2. What is the *most* popular tag on our site?
A: [debug]
B: [program]
C: [code-golf]
D: [number]
E: [c++]
answer: C
correct!
3. We are part of the ________ Exchange network.
A: Stack
B: Code
C: Programmer
D: Hockey
answer: B
incorrect! the answer was A
4. Is this the first question?
A: Yes
B: No
answer: B
correct!
5. Is this the last question?
A: Yes
B: No
answer: B
incorrect! the answer was A
overview:
3 correct, 2 incorrect (60%)
3. We are part of the ________ Exchange network.
you chose B: Code
the answer was A: Stack
5. Is this the last question?
you chose B: No
the answer was A: Yes
Formal specification:
- Input
- If a line begins with a number followed by a dot and a space, it is a question with that number. Numbers will always start from 1 and go up 1 each question.
- If a line begins with an optional asterisk, a letter, a colon, and then a space, it is an answer. Answers will also always be sequential. There will be only one correct answer per question.
- A line will not begin in any other way than the previously mentioned ways.
- Input may be accepted in any way (reading from a file, stdin, etc.) but must not be hardcoded into your program.
- Output (test-taking phase)
- First, print out each question sequentially. Print the question and its answers as recieved in input, but do not print the asterisk indicating correct answers.
- Then, print a newline and
"answer: "
. Wait for user input. User input will always correspond to an answer. - If the correct answer (the one with an asterisk) is the same as the one the user input, output
"correct!"
. Otherwise, output"incorrect! the answer was " + correct_letter
. - Separate each question with a blank line, then repeat the previous output steps until there are no more questions.
- Output (overview phase)
- Print
"overview: "
and then a newline. - Print
"{number of correct answers} correct, {incorrect answers} incorrect ({percent correct, rounded to the nearest whole number}%)"
(of course substituting the phrases in curly braces with their respective values). Then print a blank line for spacing. - Now, for each question that was wrong, print the question (not its answers), then on a new line
"you chose " + answer_you_chose
, and on another line"the answer was " + correct_answer
. Separate each wrong answer's overview with a blank line.
- Print
- In order to reduce cheating by interpreting things literally, when given the same output here, and the same input in the test-taking phase, your program must output exactly the same thing as the sample output.
This is code-golf; shortest code wins! (And gets an A+ (green checkmark)!)
\d\.
,\w:
and\*
in the middle of questions/answers. (For example currently the*
can be eliminated withy/*//
, while the correct way is lengthy ass/^\*//
.) \$\endgroup\$