ACM 2006 test tour / std.quiz

ru en cn

с начала прошло: 6631 д. 04:25
страница обновлена: 22.12.2024 22:54

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