ทำการทดสอบแบบปรนัย


14

ฉันเสนอให้คุณทดสอบ! การทดสอบของคุณคือการทดสอบ การทดสอบคือการทดสอบผู้ทดสอบด้วยการทดสอบที่ผู้ทดสอบให้ในจำนวนรหัสการทดสอบ shor คุณจะให้การทดสอบแบบปรนัยที่คุณได้รับเป็นอินพุต

ในการท้าทายนี้คุณต้องรับอินพุตดังนี้:

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 คำถามแต่ละข้อ
    • หากบรรทัดเริ่มต้นด้วยเครื่องหมายดอกจันที่เป็นตัวเลือกตัวอักษรเครื่องหมายโคลอนแล้วเว้นวรรคก็เป็นคำตอบ คำตอบจะต่อเนื่องกันเสมอ จะมีเพียงหนึ่งคำตอบที่ถูกต้องต่อคำถาม
    • บรรทัดจะไม่เริ่มต้นในวิธีอื่นใดนอกเหนือจากวิธีที่กล่าวถึงก่อนหน้านี้
    • อินพุตอาจได้รับการยอมรับในทางใดทางหนึ่ง (การอ่านจากไฟล์ stdin ฯลฯ ) แต่ต้องไม่ฮาร์ดโค้ดลงในโปรแกรมของคุณ
  • เอาท์พุท (ขั้นตอนการทดสอบ)
    • ก่อนอื่นให้พิมพ์คำถามแต่ละข้อตามลำดับ พิมพ์คำถามและคำตอบตามที่ได้รับในอินพุต แต่อย่าพิมพ์เครื่องหมายดอกจันเพื่อระบุคำตอบที่ถูกต้อง
    • "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/^\*//)
manatwork

2
เราจำเป็นต้องอนุญาตให้มีการต่อสายหรือไม่? ฉันหมายความว่าจะมีบรรทัดที่ไม่ขึ้นต้นด้วย“ 1 ” หรือ“ A:”? ถ้าใช่โปรดระบุกรณีดังกล่าวในการทดสอบตัวอย่าง
จัดการ

@manatwork (ความคิดเห็นแรก) ตกลงแก้ไข (ความคิดเห็นที่สอง) ไม่คุณไม่ได้ ฉันจะชี้แจง
Doorknob

1
แล้วคุณจะทดสอบการทดสอบนี้อย่างไร
Joe Z.

2
@JoeZ อืมม ... ไม่แน่ใจว่าคุณหมายถึงอะไร ... ฉันได้จัดทำแบบทดสอบทดสอบเพื่อทดสอบผู้ทดสอบของคุณ
Doorknob

คำตอบ:


2

Perl 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.txtperl test.pl test.txt

หากคุณเลือกตัวเลือกที่ไม่ปรากฏในรายการคุณจะได้รับผลลัพธ์ที่ไม่ถูกต้องในภาพรวม ( you chose: 1. Our site is called Programming Puzzles & Code ________.ตัวอย่างเช่นจะพูด)

ตัวอย่างการวิ่ง


กรุณาแสดงตัวอย่างของอินพุตและเอาต์พุต
DavidC

@DavidCarraher เพิ่มการเชื่อมโยงการปรับปรุงเพื่อการส่งออกผ่านทางshowterm.io ความคิดที่ว่าจะดีกว่าเอาท์พุทแบบคงที่เล็กน้อยแม้ว่ามันจะยังไม่จับมันเหมือนกับที่อยู่ในเครื่อง
Dom Hastings

นี่เป็นมุมมองที่ดีของโปรแกรมของคุณ
DavidC

3

วิชาคณิตศาสตร์ 144

นี่อาจเป็นความพยายามที่ไม่ถูกต้อง ฉันแยกคำถามออกจากแต่ละคำตอบในอินพุต ฉันยังระบุคำตอบที่ถูกต้องด้วยตัวอักษรในฟิลด์ที่แยกต่างหากแทนที่จะเป็นเครื่องหมายดอกจันหน้าตัวเลือกอื่น

อย่างไรก็ตาม...

ข้อมูล

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

ตัวเลือกโต้ตอบ


ว้าวน่าประทับใจ! การป้อนข้อมูลไม่ได้อยู่ในรูปแบบที่ถูกต้องแม้ว่า ... ยังคงเป็นสิ่งที่น่าทึ่งมากสำหรับความกะทัดรัดของรหัสและเท่าไหร่!
Doorknob

ขอบคุณ การนวดสตริงข้อมูลเข้าสู่โครงสร้างที่เป็นมิตรกับ Mathematica นั้นเป็นไปได้แน่นอน แต่มันจะต้องซ่อนความสง่างามที่แฝงอยู่ในปัจจุบันซึ่งเป็นวิธีที่ไม่เหมาะสม
DavidC

ดี ตัวละครสี่ตัวสั้นกว่า: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[...]]
Mr.Wizard

2

Java - 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

Haskell, 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 ตัวอักษรเพื่อล้าง stdout สามารถบันทึกอักขระอีก 38 ตัวหากสคริปต์ทดสอบถูกอ่านจากไฟล์คงที่ชื่อ "t" แทนที่จะระบุในบรรทัดคำสั่ง

เมื่อทำงานกับอินพุตที่ให้ไว้ในคำถาม:

& 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
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.