ШЦЭ 2019 - M9101. Машинное обучение. Базовые задачи / std.quiz

ru en cn

с начала прошло: 2129 д. 21:31
страница обновлена: 25.12.2024 15:16

std.quiz: check_quiz.py

import sys
import itertools

def PE(msg):
    print(msg)
    quit(2)
def WA(msg):
    print(msg)
    quit(1)

def check_one(o, a):
    o = o.lower()
    a = a.lower()
    return set(o.split()) == set(a.split())

try:
    fin, fout, fans = map(open, sys.argv[1:4])
    out = fout.readlines()
    ans = fans.readlines()
    #if len(out) < len(ans): PE(f"Too few lines: {len(out)} < {len(ans)}")
    if len(out) > len(ans): PE(f"Too many lines: {len(out)} > {len(ans)}")

    for i, (o, a) in enumerate(itertools.zip_longest(out, ans)):
        if o is None or not any(check_one(o, p) for p in a.split('|')):
            WA('' if len(ans) ==1 else f"line: {i + 1}")
    print("ok")
    quit(0)

except Exception as e:
    print(e)
    quit(2)
Дальневосточный федеральный университет