codegen / assets /train /deepcoder_primeintellect /deepcoder_primeintellect_04c8c5e92ceb00d4 /test_solution.py
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| cases = [{'input': '4\n1 2\n1 3\n1 4\n', 'output': '0.1250000000\n0.2916666667\n0.2916666667\n0.2916666667\n'}, {'input': '7\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n', 'output': '0.0850694444\n0.0664062500\n0.0664062500\n0.1955295139\n0.1955295139\n0.1955295139\n0.1955295139\n'}, {'input': '1\n', 'output': '1.0000000000\n'}, {'input': '10\n9 8\n7 4\n10 7\n6 7\n1 9\n4 9\n9 3\n2 3\n1 5\n', 'output': '0.0716733902\n0.1568513416\n0.0716733902\n0.0513075087\n0.1568513416\n0.1496446398\n0.0462681362\n0.1274088542\n0.0186767578\n0.1496446398\n'}, {'input': '20\n13 11\n4 12\n17 16\n15 19\n16 6\n7 6\n6 8\n12 2\n19 20\n1 8\n4 17\n18 12\n9 5\n14 13\n11 15\n1 19\n3 13\n4 9\n15 10\n', 'output': '0.0241401787\n0.0917954309\n0.0976743034\n0.0150433990\n0.1006279377\n0.0150716827\n0.0758016731\n0.0241290115\n0.0444770708\n0.0796739239\n0.0310518413\n0.0248005499\n0.0287209519\n0.0976743034\n0.0160891602\n0.0248310267\n0.0253902066\n0.0917954309\n0.0146375074\n0.0765744099\n'}, {'input': '30\n15 21\n21 3\n22 4\n5 18\n26 25\n12 24\n11 2\n27 13\n11 14\n7 29\n10 26\n16 17\n16 27\n16 1\n3 22\n5 19\n2 23\n4 10\n8 4\n1 20\n30 22\n9 3\n28 15\n23 4\n4 1\n2 7\n5 27\n6 26\n6 24\n', 'output': '0.0047521072\n0.0089582002\n0.0091024503\n0.0005692947\n0.0158713738\n0.0231639046\n0.0280364616\n0.0385477047\n0.0508439275\n0.0104849699\n0.0280364616\n0.0756812249\n0.0527268460\n0.0663906850\n0.0348291400\n0.0067068947\n0.0473003760\n0.0620785158\n0.0620785158\n0.0431676433\n0.0225005681\n0.0055308416\n0.0101877956\n0.0354105896\n0.0520300528\n0.0099339742\n0.0093540308\n0.0748580820\n0.0663906850\n0.0444766827\n'}, {'input': '2\n2 1\n', 'output': '0.5000000000\n0.5000000000\n'}, {'input': '3\n2 1\n3 2\n', 'output': '0.3750000000\n0.2500000000\n0.3750000000\n'}, {'input': '4\n3 1\n3 2\n2 4\n', 'output': '0.3125000000\n0.1875000000\n0.1875000000\n0.3125000000\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') | |