Compared against declared_pairs · told 11 of 12 deliberately broken copies apart · 2240 ms
def solve(s):
rows = 'value,kind'
tok = ''
dot = 0
i = 0
u = s + '\n'
while i < len(u):
ch = u[i]
i = i + len(ch)
if ch >= '0' and ch <= '9':
tok = tok + ch
else:
if ch == '-' and tok == '':
tok = '-'
else:
if ch == '.' and tok != '' and tok != '-' and dot == 0:
tok = tok + '.'
dot = len('.')
else:
if tok != '' and tok != '-' and tok != '.' and tok != '-.':
rows = rows + '\n' + tok + ',num'
tok = ''
dot = 0
return rows
12 test cases ship with it; the first three:
| in | out |
|---|---|
90 -2 48 90 2.5 x2 90-48 0 | value,kind 90,num -2,num 48,num 90,num 2.5,num 2,num 90,num 48,num 0,num |
34 -8 70 34 8.5 x8 34-70 1 | value,kind 34,num -8,num 70,num 34,num 8.5,num 8,num 34,num 70,num 1,num |
74 -3 28 74 3.5 x3 74-28 2 | value,kind 74,num -3,num 28,num 74,num 3.5,num 3,num 74,num 28,num 2,num |
GET https://research.zaiba.cloud/api/v1/programs/numbers_to_csv
POST https://research.zaiba.cloud/api/v1/programs/numbers_to_csv/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/numbers_to_csv/code
# 200 · text/plain · the tool as one Python file, written by the library's authors