बहुविकल्पी परीक्षा दें


14

मैं आपको एक परीक्षण के लिए प्रस्तुत करता हूं! आपकी परीक्षा की परीक्षा है। टेस्ट को टेस्टी के साथ टेस्टी को टेस्ट करना होता है, एक परीक्षक आपको कोड के शोर टेस्ट राशि में देता है । विशेष रूप से, आप एक बहु विकल्प परीक्षण देंगे जिसे आपने इनपुट के रूप में प्राप्त किया है।

इस चुनौती में, आपको इस तरह से एक इनपुट लेना होगा:

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

और यहाँ परीक्षण का एक उदाहरण लिया जा रहा है:

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

औपचारिक विनिर्देश:

  • इनपुट
    • यदि एक रेखा एक बिंदु और एक स्थान के बाद एक संख्या से शुरू होती है, तो यह उस संख्या के साथ एक प्रश्न है। नंबर हमेशा 1 से शुरू होंगे और प्रत्येक प्रश्न 1 से ऊपर जाएंगे।
    • यदि एक पंक्ति एक वैकल्पिक तारांकन, एक पत्र, एक बृहदान्त्र और फिर एक स्थान से शुरू होती है, तो यह एक उत्तर है। उत्तर भी हमेशा अनुक्रमिक होंगे। प्रति प्रश्न केवल एक सही उत्तर होगा।
    • पहले बताए गए तरीकों की तुलना में किसी भी अन्य तरीके से एक लाइन शुरू नहीं होगी।
    • इनपुट को किसी भी तरह से स्वीकार किया जा सकता है (फ़ाइल, स्टडिन आदि से पढ़ना), लेकिन आपके प्रोग्राम में हार्डकोड नहीं होना चाहिए।
  • आउटपुट (परीक्षण लेने का चरण)
    • सबसे पहले, प्रत्येक प्रश्न को क्रमिक रूप से प्रिंट करें। इनपुट में प्राप्त प्रश्न और उसके उत्तरों को प्रिंट करें, लेकिन सही उत्तरों को इंगित करने वाले तारांकन चिह्न को प्रिंट न करें।
    • फिर, एक नई रूपरेखा प्रिंट करें और "answer: "। उपयोगकर्ता इनपुट के लिए प्रतीक्षा करें। उपयोगकर्ता इनपुट हमेशा एक उत्तर के अनुरूप होगा।
    • यदि सही उत्तर (एक तारांकन वाला) उपयोगकर्ता इनपुट, आउटपुट के समान है "correct!"। अन्यथा, आउटपुट "incorrect! the answer was " + correct_letter
    • प्रत्येक प्रश्न को एक रिक्त रेखा के साथ अलग करें, फिर पिछले आउटपुट चरणों को दोहराएं जब तक कि अधिक प्रश्न न हों।
  • आउटपुट (अवलोकन चरण)
    • प्रिंट करें "overview: "और फिर एक नई रूपरेखा।
    • प्रिंट "{number of correct answers} correct, {incorrect answers} incorrect ({percent correct, rounded to the nearest whole number}%)"(बेशक अपने संबंधित मूल्यों के साथ घुंघराले ब्रेसिज़ में वाक्यांशों को प्रतिस्थापित करना)। फिर रिक्ति के लिए एक रिक्त रेखा प्रिंट करें।
    • अब, प्रत्येक प्रश्न के लिए जो गलत था, प्रश्न को प्रिंट करें (इसके उत्तर नहीं), फिर एक नई लाइन पर "you chose " + answer_you_chose, और दूसरी लाइन पर "the answer was " + correct_answer। प्रत्येक गलत उत्तर के अवलोकन को एक रिक्त रेखा के साथ अलग करें।
  • चीजों को शाब्दिक रूप से व्याख्या करके धोखा देने को कम करने के लिए, जब यहां एक ही आउटपुट दिया जाता है, और परीक्षण-चरण में एक ही इनपुट दिया जाता है, तो आपके कार्यक्रम को नमूना आउटपुट के समान बिल्कुल आउटपुट होना चाहिए।

यह ; सबसे छोटा कोड जीत! (और A + (हरा चेकमार्क) प्राप्त करता है!)


2
नाइस चुनौती है, लेकिन मैं संभवतः मुश्किल स्थितियों को शामिल नमूना परीक्षण के लिए, की तरह चाहते हैं \d\. , \w: और \*प्रश्न / उत्तर के बीच में। (उदाहरण के लिए वर्तमान में , के *साथ समाप्त किया जा सकता है y/*//, जबकि सही तरीका के रूप में लंबा है s/^\*//।)
मैंटवर्क

2
क्या हमें लाइन निरंतरता की अनुमति देने की आवश्यकता है? मेरा मतलब है, वहाँ लाइनों "1 के साथ शुरू नहीं होगा। "या" ए: "? यदि हाँ, तो ऐसे मामलों को नमूना परीक्षण में शामिल करें।
१५:१३

@manatwork (पहली टिप्पणी) ठीक है, संपादन (दूसरी टिप्पणी) नहीं, आप नहीं। मैं स्पष्ट कर दूंगा।
दरवाज़े

1
तो आप इस परीक्षा की परीक्षा कैसे दे रहे हैं?
जो जेड

2
@JoeZ। उम्म ... यकीन नहीं तुम क्या मतलब है ... मैं परीक्षण अपने परीक्षक परीक्षण करने के लिए के लिए एक परीक्षण परीक्षण का मामला प्रदान किया था
दरवाज़े

जवाबों:


2

पर्ल 5, 279

$y=correct;@w=(the,$n=answer,was);map{s/^\*((.+?):.+)/$a=$1/me;print"$_$n: ";chop($@=<>);print$@eq($l=$2)?++$d&&"$y!

":(/^\d.+/,$o.=$&,/^$@.+/m,$o.="
you chose: $&
@w $a

")&&"in$y! @w $l

"}@_=split/(?=^\d)/m,join"",<>;printf"overview:
$d $y, %d in$y (%d%)

$o",@_-$d,$d/@_*100

ध्यान दें: आउटपुट स्वरूपण के लिए नई सीमाएँ आवश्यक हैं।

हर बार मुझे लगता है कि मैं इसे और अधिक नहीं कर सकता, मैं कुछ नया सीखता हूं! यह धीरे-धीरे सुपाठ्य पाठ की तुलना में अधिक विराम चिह्न बन रहा है ... मुझे लगता है कि यह एक अच्छी बात है?

उपयोग: perl -e '...' test.txtया perl test.pl test.txt

यदि आप सूची में प्रस्तुत नहीं किया गया विकल्प चुनते हैं, तो आपको अवलोकन में गलत आउटपुट मिलेगा (यह you chose: 1. Our site is called Programming Puzzles & Code ________.उदाहरण के लिए कहेंगे )।

उदाहरण चलाते हैं


कृपया इनपुट और आउटपुट का एक उदाहरण दिखाएं।
डेविड डे

@DavidCarraher के माध्यम से उत्पादन के लिए एक अद्यतन लिंक जोड़ा showterm.io । सोचा कि यह स्थैतिक उत्पादन की तुलना में थोड़ा बेहतर होगा, हालांकि यह अभी भी इसे वैसा ही कैप्चर नहीं करता जैसा कि टर्मिनल में है।
डोम हेस्टिंग्स

यह आपके कार्यक्रम के काम करने के तरीके का एक अच्छा दृश्य देता है।
डेविड डे

3

गणितज्ञ १४४

यह एक अमान्य प्रयास हो सकता है। मैंने इनपुट में प्रत्येक उत्तर से प्रश्न को अलग कर दिया। मैंने विकल्प से पहले एक तारांकन के बजाय एक अलग क्षेत्र में एक पत्र द्वारा सही उत्तर का संकेत दिया।

वैसे भी ...

आँकड़े

questions={{{"\n1. Our site is called Programming Puzzles & Code ________.\n","A: Bugging\n","B: Golf\n","C: Hockey\n","D: Programming\n"},"B"},{{"\n2. What is the most popular tag on our site? \n","A: [debug]\n","B: [program]\n","C: [code golf]\n","D: [number]\n"},"C"},{{"\n3. We are part of the _______ Exchange network. \n","A: Stack\n","B: Code\n","C: Programmer\n","D: Hockey\n"},"A"},{{"\n4. Is this the first question? \n","A: Yes\n","B: No\n"},"B"},{{"\n5. Is this the last question? \n","A: Yes\n","B: No\n"},"A"}};

कोड

प्रत्येक प्रश्न का उत्तर एक संवाद बॉक्स के माध्यम से दर्ज किया जाता है। प्रश्न, उत्तर और प्रतिक्रिया मुद्रित हैं।

f@x_:=
Print[If[((r=ChoiceDialog[Print[""<>#,"\nanswer: "];""<>#,StringTake[Rest@#,1]])==#2),
r<>"\ncorrect!", r<>"\nincorrect, the answer is "<>#2]&@@x] 

परीक्षा

f /@ questions

संवाद विकल्प


वाह, प्रभावशाली! इनपुट सही रूप में नहीं है, हालांकि ... फिर भी, यह कोड की संक्षिप्तता के लिए बहुत उल्लेखनीय है और यह कितना काम करता है!
दरवाज़े

धन्यवाद। मैथेमेटिका-अनुकूल संरचना में इनपुट स्ट्रिंग की मालिश करना संभव है, लेकिन यह वर्तमान, अयोग्य समाधान के साथ अंतर्निहित लालित्य को छिपाएगा।
14

अच्छा लगा। चार वर्ण छोटे:g@{a_,b_}:=Print[If[(r=ChoiceDialog[Print[""<>a,"\nanswer: "];""<>a,Rest@a~StringTake~1])==b,r<>"\ncorrect!",r<>"\nincorrect, the answer is "<>b]]
Mr.Wizard

और के Print@If[...]बजाय का उपयोग करके एक और बचा Print[If[...]]
श्री। छिपकली

2

जावा - 1210

int i,o;String q;String[]s={"1. Our site is called Programming Puzzles & Code ________.\n","2. What is the most popular tag on our site?\n","3. We are part of the ________ Exchange network.\n","4. Is this the first question?\n","5. Is this the last question?\n"},b={"B","C","A","B","A"},p=new String[5];String[][]a={{"A: Debugging\n","B: Golf\n","C: Hockey\n","D: Programming\n","answer: "},{"A: [debug]\n","B: [program]\n","C: [code-golf]\n","D: [number]\n","E: [c++]\n","answer: "},{"A: Stack\n","B: Code\n","C: Programmer\n","D: Hockey\n","answer: "},{"A: Yes\n","B: No\n","answer: "},{"A: Yes\n","B: No\n","answer: "}};java.util.Map<String,Integer>m=new java.util.HashMap(){{put("A",0);put("B",1);put("C",2);put("D",3);put("E",4);}};java.util.Scanner u=new java.util.Scanner(System.in);for(i=0;i<5;i++){q=s[i];for(o=0;o<a[i].length;)q+=a[i][o++];System.out.print(q);if(b[i].equals(p[i]=u.nextLine()))q="correct!";else q="incorrect! the answer was "+b[i];System.out.println(q+"\n");}q="";o=0;for(i=0;i<5;i++)if(b[i].equals(p[i]))o++;else q+=s[i]+"you chose "+a[i][m.get(p[i])]+"the answer was "+a[i][m.get(b[i])]+"\n";System.out.println("overview:\n"+o+" correct, "+(5-o)+" incorrect ("+o*100/5+"%)\n\n"+q);

स्वरूपित: 1980

String[] s = {"1. Our site is called Programming Puzzles & Code ________.\n",
        "2. What is the most popular tag on our site?\n",
        "3. We are part of the ________ Exchange network.\n",
        "4. Is this the first question?\n",
        "5. Is this the last question?\n"};
    String[][] a = {
        {"A: Debugging\n", "B: Golf\n", "C: Hockey\n", "D: Programming\n", "answer: "},
        {"A: [debug]\n", "B: [program]\n", "C: [code-golf]\n", "D: [number]\n", "E: [c++]\n", "answer: "},
        {"A: Stack\n", "B: Code\n", "C: Programmer\n", "D: Hockey\n", "answer: "},
        {"A: Yes\n", "B: No\n", "answer: "},
        {"A: Yes\n", "B: No\n", "answer: "}};

    java.util.Map<String, Integer> m = new java.util.HashMap<String, Integer>() {
        {
            put("A", 0);
            put("B", 1);
            put("C", 2);
            put("D", 3);
            put("E", 4);
        }
    };
    String[] b = {"B", "C", "A", "B", "A"};
    String[] p = new String[5];
    java.util.Scanner u = new java.util.Scanner(System.in);
    String q;
    int i;
    int o;
    for (i = 0; i < 5; i++) {
        q = s[i];
        for (o = 0; o < a[i].length;) {
            q += a[i][o++];
        }
        System.out.print(q);
        if (b[i].equals(p[i] = u.nextLine())) {
            q = "correct!";
        } else {
            q = "incorrect! the answer was " + b[i];
        }
        System.out.println(q + "\n");
    }
    q = "";
    o = 0;
    for (i = 0; i < 5; i++) {
        if (b[i].equals(p[i])) {
            o++;
        } else {
            q += s[i] + "you chose " + a[i][m.get(p[i])] + "the answer was " + a[i][m.get(b[i])] + "\n";
        }
    }
    System.out.println("overview:\n" + " correct, " + (5 - o) + " incorrect (" + o * 100 / 5 + "%)\n\n" + q);

यह निश्चित रूप से सबसे छोटा नहीं होगा, लेकिन यह सभी आत्म-निहित है


0

हास्केल, 598

import System.Environment
import System.IO
n=putStrLn
p=putStr
d#s=p$show d++s
v&(m:a)=n m>>q[]""a>>= \(r,(s,t))->n s>>n"">>b v m t&r
(r,w,s)&[]=n"overview:">>r#" correct, ">>w#" incorrect (">>((100*r)`div`(r+w))#"%)\n">>mapM_ n s
b(r,w,s)m t|null t=(r+1,w,s)|1<3=(r,w+1,s++"":m:t)
q u c(('*':a):r)=q u a(a:r)
q u c(a@(o:':':_):r)=n a>>q(([o],a):u)c r
q u c r=p"answer: ">>hFlush stdout>>(\i->(r,a(maybe i id$lookup i u)c))`fmap`getLine
a j c|j==c=("correct!",[])|1<3=("incorrect! the answer was "++[head c],["you choose "++j,"the answer was "++c])
main=getArgs>>=readFile.head>>=((0,0,[])&).lines

अब मैं जैसा चाहता हूं, उससे ज्यादा लंबा रास्ता। यह विकी सेट है इसलिए उस पर है!

काश, हम स्टडआउट फ्लश करने के लिए 32 अक्षर खो देते हैं। यदि कमांड लाइन पर निर्दिष्ट के बजाय "t" नामक एक निश्चित फ़ाइल से परीक्षण स्क्रिप्ट पढ़ी गई थी, तो अन्य 38 वर्णों को बचाया जा सकता है।

प्रश्न में दिए गए इनपुट पर चलने पर:

& runhaskell 15961-Tester.hs 15961-test.txt 
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 choose B: Code
the answer was A: Stack

5. Is this the last question?
you choose B: No
the answer was A: Yes
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.