ЛШ 2017. Олимпиада C, D / std.quiz

ru en cn

с начала прошло: 2268 д. 05:48
страница обновлена: 27.09.2023 14:27

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)
Дальневосточный федеральный университет