import subprocess import sys from pathlib import Path cases = [{'input': '39\n', 'output': '4\n5 3 '}, {'input': '1\n', 'output': '0\n'}, {'input': '7\n', 'output': '0\n'}, {'input': '1000000\n', 'output': '7\n14 6 9 15 '}, {'input': '524288\n', 'output': '1\n19 '}, {'input': '524289\n', 'output': '2\n19 '}, {'input': '524287\n', 'output': '0\n'}, {'input': '699050\n', 'output': '19\n1 2 4 6 8 10 12 14 16 18 '}, {'input': '349525\n', 'output': '19\n0 1 3 5 7 9 11 13 15 17 '}, {'input': '2\n', 'output': '1\n1 '}, {'input': '5\n', 'output': '2\n2 '}, {'input': '6\n', 'output': '1\n1 '}, {'input': '11\n', 'output': '3\n0 2 '}, {'input': '13\n', 'output': '2\n2 '}, {'input': '545860\n', 'output': '11\n19 2 6 10 12 14 '}, {'input': '917503\n', 'output': '3\n0 17 '}, {'input': '174762\n', 'output': '17\n1 2 4 6 8 10 12 14 16 '}, {'input': '43690\n', 'output': '15\n1 2 4 6 8 10 12 14 '}, {'input': '10922\n', 'output': '13\n1 2 4 6 8 10 12 '}, {'input': '2730\n', 'output': '11\n1 2 4 6 8 10 '}] 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')