Vi presento un test! Il tuo test è testare. Il test è quello di testare la testee con i test di un tester ti dà, in shor prova di quantità di codice. In particolare, eseguirai un test a scelta multipla che hai ricevuto come input.
In questa sfida, devi prendere un input come questo:
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
Ed ecco un esempio del test che viene eseguito:
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
Specifica formale:
- Ingresso
- Se una linea inizia con un numero seguito da un punto e uno spazio, è una domanda con quel numero. I numeri inizieranno sempre da 1 e saliranno 1 per ogni domanda.
- Se una riga inizia con un asterisco opzionale, una lettera, due punti e quindi uno spazio, è una risposta. Anche le risposte saranno sempre sequenziali. Ci sarà una sola risposta corretta per domanda.
- Una linea non inizierà in altro modo rispetto ai modi precedentemente menzionati.
- L'input può essere accettato in qualsiasi modo (lettura da un file, stdin, ecc.) Ma non deve essere codificato nel programma.
- Uscita (fase di test)
- Per prima cosa, stampa ogni domanda in sequenza. Stampa la domanda e le sue risposte come ricevute nell'input, ma non stampare l'asterisco che indica le risposte corrette.
- Quindi, stampare una nuova riga e
"answer: ". Attendi l'input dell'utente. L'input dell'utente corrisponderà sempre a una risposta. - Se la risposta corretta (quella con un asterisco) è la stessa di quella immessa dall'utente, viene emessa
"correct!". Altrimenti, output"incorrect! the answer was " + correct_letter. - Separare ogni domanda con una riga vuota, quindi ripetere i passaggi di output precedenti fino a quando non ci sono più domande.
- Uscita (fase panoramica)
- Stampa
"overview: "e poi una riga. - Stampa
"{number of correct answers} correct, {incorrect answers} incorrect ({percent correct, rounded to the nearest whole number}%)"(ovviamente sostituendo le frasi tra parentesi graffe con i rispettivi valori). Quindi stampare una riga vuota per la spaziatura. - Ora, per ogni domanda errata, stampare la domanda (non le sue risposte), quindi su una nuova riga
"you chose " + answer_you_chosee su un'altra riga"the answer was " + correct_answer. Separare la panoramica di ogni risposta errata con una riga vuota.
- Stampa
- Per ridurre i cheat interpretando le cose letteralmente, quando viene fornito lo stesso output qui e lo stesso input nella fase di test, il tuo programma deve produrre esattamente lo stesso output del campione.
Questo è code-golf ; vince il codice più corto! (E ottiene un A + (segno di spunta verde)!)

\d\.,\w:e\*nel bel mezzo di domande / risposte. (Ad esempio attualmente è*possibile eliminare cony/*//, mentre il modo corretto è lungo comes/^\*//.)