내 스캔 트론 등급을 매기십시오!


10

표준화 된 테스트는 일반적으로 스캔 트론 또는 답변을 기록하는 일부 유형의 답변 문서와 함께 제공됩니다. 그러면 컴퓨터 나 사람이 답변을 확인하고 성적을 결정합니다. 따라서 여기에 스캔 트론과 응답 키가 주어지면 점수와 누락 된 질문이 있는지 확인하십시오. 스캔 트론은 사용자가 채운 답변이있는 여러 줄의 문서 (이 경우에는 동그라미로 표시됨)입니다. 예:

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

보시다시피, 이것은 a주위에 상자가 있으므로 답변 선택이 선택된 질문 1입니다 . 도전의 경우와 스캔 론 받게됩니다 n질문 ( 1 <= n <= 10로 표시 네 개의 답변을) a, b, c, 또는 d. 응답 키는 공백과 소문자가 모두 포함 된 문자열로 제공됩니다. 응답 키가 포함 된 예시 스캔 트론 :

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

Answer Key
abb

응답 키와 스캔 트론을 별도의 입력으로 또는 식별 할 수있는 한 선택한 순서대로 응답 키를 사용할 수 있습니다 (즉, 응답 키가 스캔 트론과 분리되어 있음). 점수는 가장 가까운 10 분의 1로 반올림됩니다. 위의 예제 출력 :

Score: 66.7
Missed #: 3

다른 대답은 다음과 같습니다.

66.7 
3

또는 여러 질문이 누락 된 경우

66.7
3 4 5

결석 한 사람의 질문 번호는 공백과 구분되며 점수와 같은 줄에 있지 않습니다.

규칙 및 사양

  • 스캔 트론은 한 번에 여러 줄로 된 문자열 또는 한 개의 질문으로 입력 할 수 있습니다 (줄 바꿈이있는 문자열이 허용됨)
  • 스캔 트론과 응답 키가 주어지면 한 줄에 점수를, 다른 줄에 놓친 질문은 공백으로 구분하여 출력해야합니다. 누락 된 질문이 없으면 질문 번호를 출력하지 않아야합니다.
  • 점수는 10 분의 1로 반올림됩니다
  • 선택된 답변은이 상자로 둘러싸여 있습니다.

    ---
    | |
    ---
    
  • 스캔 트론에서 모든 질문에는 3 칸의 공간이 필요합니다 (상자의 맨 위와 맨 아래에는 2 줄이 더 필요합니다)
  • 위 예제에서 작동해야합니다
  • 항상 하나의 답변 상자 만 있다고 가정하십시오.

승리 기준

최단 코드 승리!


scan-tron은 질문 목록이 될 수 있습니까? 그리고 각 질문은 줄 바꿈이있는 단일 문자열입니까?
Rod

@로드 예 그리고 나는 그것을 명확히 할 것이다
Anthony Pham

2
는 "누락"문제는 학생이하는 질문을 의미 할 수 있기 때문에, 나에게 혼란 "놓친"의 언어 답 실패 (당신의 명백한 의미에 반대는 잘못 대답 ).
DLosc

@DLosc 항상 하나의 원으로 된 답이있을 것입니다
Anthony Pham

50허용되는 점수입니까 , 아니면 맞 50.0습니까?
DLosc

답변:


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 "...")

스택 맨 위에서 두 개의 입력을받습니다.

몇 가지 흥미로운 기능 :

[#'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

파이썬 2 , 94 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

3

, 49 46 44 48 45 바이트

그 반올림에는 너무 많은 바이트가 필요합니다 ... 44 바이트의 코드, -s플래그의 경우 +1 .

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

입력을 명령 행 인수로 사용합니다 (실제 명령 행에서 실행하는 경우 scan-tron 페이지에서 줄 바꾸기를 인용하고 이스케이프해야 함). 누락 된 질문을 먼저 출력 한 다음 점수를 출력합니다. 온라인으로 사용해보십시오!

설명

잘못된 질문 목록과 점수라는 두 부분으로이 작업을 수행합니다.

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

자바 스크립트 (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

쉼표를 사용하고 모든 것을 한 줄로 반환하여 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질문 행을 읽습니다 . 참고 :보다 작 으면 점수는 앞에 0이 표시되지 않습니다 1.0. 누락 된 답변은 선행 공백으로 인쇄됩니다.


0

CJam , 47 45 바이트

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

온라인으로 사용해보십시오!

설명

이 프로그램은 세 가지 주요 부분으로 구성됩니다.

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

줄프, 46 바이트

46 바이트를 깰 수없는 것 같습니다. 이 길이의 두 가지 해결책이 있습니다. 여기서 시도하십시오!

Ά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.