import subprocess import sys from pathlib import Path cases = [{'input': '3\n11\n', 'output': '1\n'}, {'input': '3\n99\n', 'output': '0\n'}, {'input': '10\n5205602270\n', 'output': '0\n'}, {'input': '70\n3326631213\n', 'output': '6\n'}, {'input': '200\n1000000010000000000000000000010000000000000001000001000000000000000000000000000000000000000000000000\n', 'output': '22\n'}, {'input': '500\n1899337170458531693764539600958943248270674811247191310452938511077656066239840703432499357537079035\n', 'output': '6\n'}, {'input': '700\n9307216756404590162143344901558545760612901767837570518638460182990196397856220673189163417019781185\n', 'output': '32\n'}, {'input': '900\n7570423817272967027553082464863962024635217372307919506594193055572300657732661146354209508997483330\n', 'output': '91\n'}, {'input': '18\n900\n', 'output': '1\n'}, {'input': '23\n12138\n', 'output': '1\n'}, {'input': '16\n333\n', 'output': '2\n'}, {'input': '3\n12\n', 'output': '0\n'}, {'input': '3\n111\n', 'output': '0\n'}, {'input': '1\n100\n', 'output': '0\n'}, {'input': '17\n89\n', 'output': '0\n'}, {'input': '18\n99\n', 'output': '0\n'}, {'input': '42\n97779\n', 'output': '2\n'}, {'input': '2\n11\n', 'output': '0\n'}, {'input': '6\n33\n', 'output': '0\n'}, {'input': '45\n23456\n', 'output': '5\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')