File size: 1,854 Bytes
01a492e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

import subprocess
import sys
from pathlib import Path

cases = [{'input': '4 3\n', 'output': '2\n'}, {'input': '5 5\n', 'output': '1\n'}, {'input': '8 4\n', 'output': '-1\n'}, {'input': '1000000000000000000 1000000000\n', 'output': '-1\n'}, {'input': '499999998500000001 1000000000\n', 'output': '999955279\n'}, {'input': '499999998500000000 1000000000\n', 'output': '999955279\n'}, {'input': '499999999500000000 1000000000\n', 'output': '999999998\n'}, {'input': '499999999500000001 1000000000\n', 'output': '999999999\n'}, {'input': '525 34\n', 'output': '25\n'}, {'input': '223265034477 726990\n', 'output': '440662\n'}, {'input': '15597035789572051 185473109\n', 'output': '128849771\n'}, {'input': '499999999500000002 1000000000\n', 'output': '-1\n'}, {'input': '1 1000000000\n', 'output': '0\n'}, {'input': '1000000000 2\n', 'output': '-1\n'}, {'input': '462498979 204468265\n', 'output': '3\n'}, {'input': '2107921 542531\n', 'output': '4\n'}, {'input': '131 49\n', 'output': '3\n'}, {'input': '20171878992939541 200857557\n', 'output': '200853401\n'}, {'input': '399812655947 894219\n', 'output': '893030\n'}, {'input': '93 17\n', 'output': '8\n'}]
solution = Path(__file__).with_name("solution.py")
for index, case in enumerate(cases):
    proc = subprocess.run(
        [sys.executable, str(solution)],
        input=case["input"],
        text=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        timeout=10,
    )
    if proc.returncode != 0:
        raise AssertionError(f"case {index} exited {proc.returncode}: {proc.stderr}")
    got = proc.stdout.strip()
    expected = case["output"].strip()
    if got.split() != expected.split():
        raise AssertionError(
            f"case {index} output mismatch\nexpected={expected!r}\ngot={got!r}\nstderr={proc.stderr}"
        )
print('deepcoder_primeintellect_io')