Compared against declared_pairs · told 12 of 12 deliberately broken copies apart · 2029 ms
def tweak(ch):
if ch == '\n':
return '\n'
if ch == '\r':
return '\r'
if ch == '\t':
return '\t'
if ch == ' ':
return ' '
if ch == '%':
return '%'
if ch == '&':
return '&'
return ch
def solve(s):
words = []
cur = ''
for ch in s:
ch = tweak(ch)
if ch == ' ':
if cur != '':
words = words + [cur]
cur = ''
else:
if ch == '\n':
if cur != '':
words = words + [cur]
cur = ''
else:
if ch == '\t':
if cur != '':
words = words + [cur]
cur = ''
else:
if ch == '\r':
if cur != '':
words = words + [cur]
cur = ''
else:
cur = cur + ch
if cur != '':
words = words + [cur]
out = '['
i = 0
n = len(words)
while i < n:
if i > 0:
out = out + ','
w = words[i]
out = out + '"'
for ch in w:
if ch == '"':
out = out + '\\"'
else:
if ch == '\\':
out = out + '\\\\'
else:
out = out + ch
out = out + '"'
i = i + 1
return out + ']'
12 test cases ship with it; the first three:
| in | out |
|---|---|
vdxt tyl vdxt squge 0 | ["vdxt","tyl","vdxt","squge","0"] |
njxrz mibmw njxrz njzjgu 1 | ["njxrz","mibmw","njxrz","njzjgu","1"] |
jth gmzr jth yep 2 | ["jth","gmzr","jth","yep","2"] |
GET https://research.zaiba.cloud/api/v1/programs/words_to_json
POST https://research.zaiba.cloud/api/v1/programs/words_to_json/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/words_to_json/code
# 200 · text/plain · the tool as one Python file, written by the library's authors