私のスキャントロンを評価してください!


10

標準化されたテストには通常、スキャントロンまたは回答を記録するある種の回答ドキュメントが付属しています。コンピュータまたは人間があなたの答えをチェックし、あなたの成績を決定します。したがって、ここでは、スキャントロンと解答キーを与えられて、もしあれば、得点と見逃された質問を決定します。スキャントロンは、ユーザーが記入する(この場合は丸で囲まれた)回答のある複数行のドキュメントです。例:

   ---
1. |a| b c d
   --- 

ご覧のaように、ボックスで囲まれているため、これは回答の選択肢が選択された質問1 です。挑戦のために、あなたがスキャン-TRONが与えられますn(質問1 <= n <= 10と表記のみ4の答えで)abc、またはd。回答キーは、スペースのない、すべて小文字の文字列として与えられます。回答キー付きのスキャントロンの例:

Scan-tron
   ---
1. |a| b c d
   ---
     ---
2. a |b| c d
     ---
       ---
3. a b |c| d
       ---

Answer Key
abb

識別できる限り、回答キーとスキャントロンを別々の入力として、または選択した順序で取り込むことができます(つまり、回答キーがスキャントロンから分離されています)。スコアは、小数点以下第1位に丸められます。上記の出力例:

Score: 66.7
Missed #: 3

他の許容できる答えは次のとおりです。

66.7 
3

または複数の質問が欠落している場合

66.7
3 4 5

見逃された人の質問番号がスペースで区切られ、スコアと同じ行にない限り。

ルールと仕様

  • スキャントロンは、複数行の文字列として入力することも、一度に1つの質問として入力することもできます(改行を含む文字列を使用できます)。
  • スキャントロンと解答キーが与えられた場合、1行にスコアを出力し、別の行では見逃した質問をスペースで区切られた数値で出力する必要があります。見逃された質問がない場合、質問番号は出力されません。
  • スコアは10分の1に四捨五入されます
  • 選択した回答はこのボックスで囲まれています。

    ---
    | |
    ---
    
  • スキャントロンでは、すべての質問に3つのスペースが必要です(ボックスの上部と下部に2行追加されます)。
  • 上記の例で機能する必要があります
  • 常に1つの回答のみがボックス化されていると仮定します

受賞基準

最短のコードが勝ちます!


スキャントロンは質問のリストになりますか?そして、各質問は改行を含む単一の文字列ですか?
ロッド

@Rodはい、私はそれを明確にします
Anthony Pham

2
「見逃された」という質問は、学生が答えなかった質問を意味する可能性があるため、「見落とされた」という言葉は混乱を招きます(見た目の意味と対照的に、正しく答えられなかった)。
DLosc 2017年

@DLosc円で囲まれた回答は常に1つしかありません
Anthony Pham

スコアは50許容範囲内50.0ですか、それともそうである必要がありますか?
DLosc 2017年

回答:


2

05AB1E、43バイト

U|3ôø`\vyy'|k>èXNèQˆ}¯OXg/3°*2z+ïT/XgL¯_Ï‚»

オンラインでお試しください!

説明

U                                            # store the answer key in X
 |3ô                                         # split the question-rows in chunks of 3
    ø`                                       # zip and flatten
      \                                      # discard top of stack, leaving the list of
                                             # answer rows on top
       v                                     # for each answer row
         y'|k                                # get the index of the first "|"
        y    >è                              # get the character after that from the row
               XNèQ                          # compare it to the corresponding entry in 
                                             # the answer key
                   ˆ                         # add it to the global list
                    }                        # end loop
                     ¯O                      # calculate the number of correct answers
                       Xg/                   # divide by the length of the answer key
                          3°*                # multiply by 1000
                             2z+             # add 0.5
                                ï            # convert to integer
                                 T/          # divide by 10
                                   XgL       # push range [1 ... len(answer key)]
                                      ¯_Ï    # keep only numbers corresponding to 
                                             # wrong answers
                                          ‚» # format output

4

スタック、68 + 1 = 69バイト

'|'split[#'1-]NO neq::size:@z~>*[]YES' '#`out is0 sum z/100*1 nround

オンラインでお試しください!-pフラグの+1 (このスクリプトはとして実行できますstacked -pe "..."

スタックの一番上から2つの入力を受け取ります。

いくつかの興味深い機能:

[#'1-]NO
[    ]NO   do not keep members where
 #'          its length
   1-          -1
             is truthy (in this case, not equal to zero).

これにより、パイプで囲まれたすべての文字が生成されます。

:size:@z~>*[]YES
:                 duplicate indices of incorrect answers
 size             length of incorrect answers
     :@z          (stored into z)
        ~>        range from 1 to this length
          *       and multiply by this range
           []YES  keep truthy elements

これにより、すべての不正な質問番号が返されます。


3

Pythonの294の 93バイト

L3viathanのおかげで-1バイト

s,a=input()
l=len(s)
w=[i+1for i in range(l)if"|%s|"%a[i]not in s[i]]
print(l-len(w))*1e2/l,w

オンラインでお試しください!


いいですね、私のよりずっといいです。あなたは置き換えることができ100.1e2
L3viathan

これはスコアを「小数点以下の10分の1」に丸める要件を満たしているとは思えません。
DLosc 2017年

3

ピップ49 46 44 48 45バイト

ああ、その丸めには非常に多くのバイトが必要です...コードの44バイト、-sフラグの+1 。

(/2+m-m/#b*#P_FI{++nbNa?un}MZa@`\|..`b)//1/t

入力をコマンドライン引数として受け取ります(実際のコマンドラインから実行する場合、スキャントロンページでは改行の引用とエスケープが必要になります)。見逃した質問を最初に出力し、次にスコアを出力します。オンラインでお試しください!

説明

これを2つの部分で行います。不正解の質問リストとスコアです。

P_FI{++nbNa?un}MZa@`\|..`b
                            a,b are cmdline args, u is nil, n is newline (implicit)
                            Note that a string like n, in math contexts, is equivalent to 0
                 a@`\|..`   Find all occurrences in a of | followed by 2 chars
                            Because regex matches don't overlap, this does what we need
    {         }MZ        b  Zip with b and map this function to each pair of items:
     ++n                     Increment n (so the first time through, it's 1)
        bNa                  Is 2nd arg a substring of 1st?
           ?un               If so, return nil; if not, return n
                            Now we have a list containing nil for correct questions
                            and the question number for incorrect questions
 _FI                        Filter on identity function (keep only truthy values)
P                           Print, joining on spaces (-s flag)

(/2+m-m/#b*#...)//1/t
                       a,b are cmdline args, m is 1000 (implicit)
            ...        The code from the first part
           #           Length of that list (i.e. number of incorrect questions)
      m/#b*            Times 1000/(number of questions)
    m-                 Subtracted from 1000
 /2+                   Plus 1/2 (= 0.5)
                       We now have a number like 667.1666666666667
(              )//1    Int-divide by 1 to truncate
                   /t  and divide that by 10
                       Print (implicit)

2

JavaScript(ES6)、88バイト

x=>y=>x.replace(/\w(?=\|)/g,c=>c==y[i++]?t++:a+=i+" ",a=i=t="")&&(t/i*1e3+.5|0)/10+`
`+a

コンマを使用してすべてを1行で返すことにより、5バイトを節約できます。

x=>y=>x.replace(/\w(?=\|)/g,c=>c==y[i++]?t++:a+=[,i],a=i=t="")&&(t/i*1e3+.5|0)/10+a

1

バッチ、242バイト

@echo off
set/as=c=0
set m=
set/pk=
:l
set/ac+=1
set/pt=
set/pl=
set/pt=
set "l=%l:*|=%
if %l:~,1%==%k:~,1% (set/as+=1)else set m=%m% %c%
set k=%k:~1%
if not "%k%"=="" goto l
set/as=(s*2000/c+1)/2
echo(%s:~,-1%.%s:~-1%
echo(%m%

まずSTDINの回答キーを読み取り、次にn*3質問行を読み取ります。注:スコアが未満の場合、先行ゼロなしで印刷され1.0ます。逃した回答は、先頭にスペースが付いて印刷されます。


0

CJam47 45バイト

lqN/(;3%_'|f#:).=.=__:+\,d/e2XmOn:!_,,:).*0-p

オンラインでお試しください!

説明

プログラムは3つの主要部分に分かれています。

Right/wrong list

l                    e# Read the first line of input (answer key)
 qN/                 e# Read the rest of the input and split it on newlines
    (;3%             e# Delete the first line, then select every 3rd line 
        _            e# Duplicate the array
         '|f#        e# Find the index of the first | in each answer
             :)      e# Increment each, gives the index of the selected letter for each answer
               .=    e# Vectorized get-element-at with the answer strings
                 .=  e# Vectorized equality check with the answer key

このセクションの後に、0sと1sの配列があり0ます。ここで、は間違った答えと正しい答えを示し1ます。

Score

__              e# Duplicate the right/wrong list twice
  :+            e# Take the sum of it (number of right answers)
    \,          e# Swap top elements and take the length (total number of questions)
      d/        e# Divide (casting to double so it's not integer division)
        e2      e# Multiply by 10^2
          XmO   e# Round to 1 decimal place
             n  e# Pop and print with a newline

このセクションの後、スタックには正しい/間違ったリストのみが含まれ、パーセンテージスコアが出力されました。

Wrong answers

:!            e# Logically negate each element of the right/wrong list
  _,,:)       e# Generate the inclusive range 1...length(list)
       .*     e# Vectorized multiplication of the two lists
         0-   e# Remove any 0s from the result
           p  e# Print it

0

Jolf、46バイト

46バイトを壊すことができないようです。この長さの2つの解決策があります。こちらからお試しください!

ΆRγψ~mΖ mi«\|..»d?=€H.xSEhSdHήSmX*~1/-lζlγlζ_1

(次のものと交換0x7f

ΆRγψΜΖψGi'|d=1lHd?□=H.xShSEdHήSmX*~1/-lζlγlζ_1

どちらの場合も、丸めに15バイト:mX*~1/-lζlγlζ_1。正規表現の一致を使用して結果を取得し、他のパイプで分割することを除いて、ほとんどの場合、それらは同じです。

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.