Compared against declared_pairs · told 2 of 2 deliberately broken copies apart · 1471 ms
def nums(s):
out = []
cur = ''
for ch in s + ' ':
isd = ch in '0123456789'
if isd or (ch == '-' and cur == '') or (ch == '.' and cur != '' and cur != '-' and '.' not in cur):
cur = cur + ch
else:
if cur != '' and cur != '-' and cur != '.' and cur != '-.':
if '.' in cur:
out = out + [float(cur)]
else:
out = out + [int(cur)]
cur = ''
return out
def solve(s):
xs = sorted(nums(s))
return round(xs[len(xs) // 2] * 1.0, 6)
12 test cases ship with it; the first three:
| in | out |
|---|---|
46 -4 78 46 4.5 x4 46-78 0 | 46.0 |
22 -2 63 22 2.5 x2 22-63 1 | 22.0 |
18 -3 46 18 3.5 x3 18-46 2 | 18.0 |
GET https://research.zaiba.cloud/api/v1/programs/numbers_median
POST https://research.zaiba.cloud/api/v1/programs/numbers_median/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/numbers_median/code
# 200 · text/plain · the tool as one Python file, written by the library's authors