import subprocess import sys from pathlib import Path cases = [{'input': '5 2 6 3\n', 'output': '2\n'}, {'input': '3 1 5 6\n', 'output': '8\n'}, {'input': '8 3 3 2\n', 'output': '2\n'}, {'input': '2 3 10 4\n', 'output': '3\n'}, {'input': '1000000000 1000000000 1000000000 1000000000\n', 'output': '2000000000\n'}, {'input': '500000000 250000000 750000000 1000000000\n', 'output': '1500000000\n'}, {'input': '1 3 2 5\n', 'output': '8\n'}, {'input': '2 3 1 6\n', 'output': '10\n'}, {'input': '9 6 2 5\n', 'output': '3\n'}, {'input': '1 1 1 1\n', 'output': '2\n'}, {'input': '1 1 500 10\n', 'output': '10\n'}, {'input': '500 1 500 1000\n', 'output': '1501\n'}, {'input': '1 2 1 1\n', 'output': '1\n'}, {'input': '89 983 751 1000\n', 'output': '1106\n'}, {'input': '716270982 22102638 553198855 1000000000\n', 'output': '1305831656\n'}, {'input': '1000000000 1 1000000000 999999999\n', 'output': '999999999\n'}, {'input': '999999999 1 1 1000000000\n', 'output': '1000000002\n'}, {'input': '1 2 3 4\n', 'output': '6\n'}, {'input': '1 3 4 5\n', 'output': '7\n'}, {'input': '1 3 2 6\n', 'output': '10\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')