Compared against declared_pairs · told 6 of 6 deliberately broken copies apart · 1470 ms
def solve(s):
raw = []
buf = ''
i = 0
n = len(s)
while i < n:
ch = s[i]
if ch == ',':
raw = raw + [buf]
buf = ''
else:
buf = buf + ch
i = i + len(ch)
raw = raw + [buf]
out = '['
first = True
for item in raw:
a = 0
b = len(item)
while a < b and item[a] == ' ':
a = a + len(' ')
while b > a and item[b - len(' ')] == ' ':
b = b - len(' ')
item = item[a:b]
if not first:
out = out + ','
out = out + '"' + item + '"'
first = False
out = out + ']'
return out
12 test cases ship with it; the first three:
| in | out |
|---|---|
rlzr, xko ,jglns,0 | ["rlzr","xko","jglns","0"] |
lgz, hhpu ,uqzg,1 | ["lgz","hhpu","uqzg","1"] |
dydgg, csqbf ,npprdc,2 | ["dydgg","csqbf","npprdc","2"] |
GET https://research.zaiba.cloud/api/v1/programs/csv_to_json
POST https://research.zaiba.cloud/api/v1/programs/csv_to_json/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/csv_to_json/code
# 200 · text/plain · the tool as one Python file, written by the library's authors