Compared against declared_pairs · told 12 of 12 deliberately broken copies apart · 2011 ms
def kind_of(ch):
kind = 0
if ch == '"':
kind = 1
if ch == '\\':
kind = 2
if ch == '\n':
kind = 3
if ch == '\r':
kind = 4
if ch == '\t':
kind = 5
if ch == '\b':
kind = 6
return kind
def solve(s):
out = '"'
for ch in s:
kind = kind_of(ch)
if kind == 1:
out = out + '\\"'
else:
if kind == 2:
out = out + '\\\\'
else:
if kind == 3:
out = out + '\\n'
else:
if kind == 4:
out = out + '\\r'
else:
if kind == 5:
out = out + '\\t'
else:
if kind == 6:
out = out + '\\b'
else:
out = out + ch
return out + '"'
12 test cases ship with it; the first three:
| in | out |
|---|---|
xgofhp msod xgofhp ejqoo 0 | "xgofhp msod\nxgofhp ejqoo 0" |
efsn yckaqb efsn hui 1 | "efsn yckaqb\nefsn hui 1" |
owlxq ldmdb owlxq cjlg 2 | "owlxq ldmdb\nowlxq cjlg 2" |
GET https://research.zaiba.cloud/api/v1/programs/json_quote
POST https://research.zaiba.cloud/api/v1/programs/json_quote/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/json_quote/code
# 200 · text/plain · the tool as one Python file, written by the library's authors