File size: 2,531 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': '6\n+ 12001\n- 12001\n- 1\n- 1200\n+ 1\n+ 7\n', 'output': '3'}, {'input': '2\n- 1\n- 2\n', 'output': '2'}, {'input': '2\n+ 1\n- 1\n', 'output': '1'}, {'input': '5\n+ 1\n- 1\n+ 2\n+ 3\n- 4\n', 'output': '3'}, {'input': '3\n- 1\n- 2\n- 3\n', 'output': '3'}, {'input': '4\n+ 1\n+ 2\n- 1\n+ 3\n', 'output': '2'}, {'input': '6\n+ 1\n+ 2\n- 1\n+ 3\n- 2\n+ 4\n', 'output': '2'}, {'input': '3\n+ 1\n+ 2\n- 3\n', 'output': '3'}, {'input': '3\n- 1\n+ 2\n- 2\n', 'output': '1'}, {'input': '4\n- 1\n- 2\n+ 3\n+ 4\n', 'output': '2'}, {'input': '1\n+ 1\n', 'output': '1'}, {'input': '1\n- 1\n', 'output': '1'}, {'input': '3\n- 1\n+ 1\n- 1\n', 'output': '1'}, {'input': '10\n+ 1\n+ 2\n+ 3\n+ 4\n+ 5\n+ 6\n+ 7\n+ 8\n+ 9\n+ 10\n', 'output': '10'}, {'input': '5\n+ 5\n+ 4\n- 4\n- 5\n+ 5\n', 'output': '2'}, {'input': '50\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n', 'output': '1'}, {'input': '10\n- 8\n- 4\n+ 8\n+ 10\n+ 6\n- 8\n+ 9\n- 2\n- 7\n+ 4\n', 'output': '5'}, {'input': '20\n+ 3\n- 3\n- 2\n+ 2\n+ 3\n- 5\n- 1\n+ 1\n- 3\n+ 4\n- 1\n+ 1\n+ 3\n- 3\n+ 5\n- 2\n- 1\n+ 2\n+ 1\n- 5\n', 'output': '4'}, {'input': '50\n+ 4\n+ 5\n+ 3\n+ 2\n- 2\n- 3\n- 4\n+ 3\n+ 2\n- 3\n+ 4\n- 2\n- 4\n+ 2\n+ 3\n- 3\n- 5\n- 1\n+ 4\n+ 5\n- 5\n+ 3\n- 4\n- 3\n- 2\n+ 4\n+ 3\n+ 2\n- 2\n- 4\n+ 5\n+ 1\n+ 4\n+ 2\n- 2\n+ 2\n- 3\n- 5\n- 4\n- 1\n+ 5\n- 2\n- 5\n+ 5\n+ 3\n- 3\n+ 1\n+ 3\n+ 2\n- 1\n', 'output': '5'}, {'input': '10\n- 2\n+ 1\n- 1\n+ 2\n- 2\n+ 2\n+ 1\n- 1\n- 2\n+ 1\n', 'output': '2'}]
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')