Compared against declared_pairs · told 11 of 12 deliberately broken copies apart · 1814 ms
def solve(s):
lines = []
cur = ''
for ch in s:
if ch == '\n':
lines = lines + [cur]
cur = ''
else:
cur = cur + ch
if cur != '':
lines = lines + [cur]
out = []
for l in lines:
l = l[0:]
while l != '' and l[0] in ' \t':
l = l[1:]
while l != '' and l[-1] in ' \t':
l = l[:-1]
out = out + [l]
res = '['
for i in range(len(out)):
if i > 0:
res = res + ','
res = res + '"'
for ch in out[i]:
if ch == '"':
res = res + '\\"'
elif ch == '\\':
res = res + '\\\\'
else:
res = res + ch
res = res + '"'
res = res + ']'
return res
12 test cases ship with it; the first three:
| in | out |
|---|---|
bcpa Zctl bcpa Zed zctl0 apple borloi | ["bcpa","Zctl","bcpa","Zed","zctl0","apple","borloi"] |
was Gdw was Zed gdw1 apple hyid | ["was","Gdw","was","Zed","gdw1","apple","hyid"] |
hludhx Ydsv hludhx Zed ydsv2 apple jdlv | ["hludhx","Ydsv","hludhx","Zed","ydsv2","apple","jdlv"] |
GET https://research.zaiba.cloud/api/v1/programs/lines_to_json_array
POST https://research.zaiba.cloud/api/v1/programs/lines_to_json_array/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/lines_to_json_array/code
# 200 · text/plain · the tool as one Python file, written by the library's authors