Муниципальная олимпиада 2023 Камчатский край 9-11 класс / std.quiz

ru en cn

с начала прошло: 377 д. 17:29
страница обновлена: 31.12.2024 03:29

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