codegen / assets /train /deepcoder_primeintellect /deepcoder_primeintellect_039eafec96954cf5 /test_solution.py
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| cases = [{'input': '3\n2 3 1\n', 'output': '1.916666666666666666666666666667\n'}, {'input': '1\n1\n', 'output': '0.000000000000000000000000000000\n'}, {'input': '2\n1 2\n', 'output': '0.166666666666666666666666666667\n'}, {'input': '2\n2 1\n', 'output': '0.833333333333333333333333333333\n'}, {'input': '3\n1 2 3\n', 'output': '0.416666666666666666666666666667\n'}, {'input': '3\n2 1 3\n', 'output': '1.083333333333333333333333333333\n'}, {'input': '3\n3 1 2\n', 'output': '1.916666666666666666666666666667\n'}, {'input': '3\n1 3 2\n', 'output': '1.083333333333333333333333333333\n'}, {'input': '3\n3 2 1\n', 'output': '2.583333333333333333333333333333\n'}, {'input': '4\n1 4 2 3\n', 'output': '2.150000000000000000000000000000\n'}, {'input': '4\n4 2 3 1\n', 'output': '4.650000000000000000000000000000\n'}, {'input': '10\n1 2 3 4 5 6 7 8 9 10\n', 'output': '4.500000000000000000000000000000\n'}, {'input': '10\n10 1 9 2 8 3 7 4 6 5\n', 'output': '24.863636363636363636363636363636\n'}, {'input': '10\n1 6 2 7 3 8 4 9 5 10\n', 'output': '11.954545454545454545454545454545\n'}, {'input': '12\n2 12 9 3 6 11 8 1 4 10 7 5\n', 'output': '34.480769230769230769230769230769\n'}, {'input': '33\n16 17 8 15 3 29 1 18 21 14 4 31 30 20 13 7 19 22 23 25 5 11 27 24 26 9 6 33 12 2 28 32 10\n', 'output': '235.611408199643493761140819964349\n'}, {'input': '33\n9 16 4 17 13 32 5 6 1 31 22 8 11 27 15 7 33 25 20 3 12 29 14 10 21 2 30 26 24 23 18 28 19\n', 'output': '218.028520499108734402852049910873\n'}, {'input': '33\n11 9 16 30 33 31 8 5 21 3 7 18 32 26 28 27 29 1 24 2 6 20 17 13 14 12 25 23 19 22 4 10 15\n', 'output': '286.689839572192513368983957219251\n'}, {'input': '33\n24 7 31 16 10 13 14 20 28 23 29 2 18 25 8 19 17 30 32 4 9 26 5 15 3 1 33 11 12 21 6 27 22\n', 'output': '274.721925133689839572192513368984\n'}, {'input': '100\n30 99 96 51 67 72 33 35 93 70 25 24 6 9 22 83 86 5 79 46 29 88 66 20 87 47 45 71 48 52 61 37 19 40 44 11 8 42 63 92 31 94 2 4 28 77 21 75 13 95 76 14 53 69 54 38 59 60 98 55 39 68 85 23 15 18 58 78 43 49 16 1 82 91 7 84 34 89 17 27 90 26 36 81 64 74 50 57 10 73 12 62 3 100 80 32 56 41 97 65\n', 'output': '2453.709603960396039603960396039604\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') | |