Compared against declared_pairs · told 12 of 12 deliberately broken copies apart · 2075 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):
out = ''
gap = 0
started = 0
for ch in s:
ch = tweak(ch)
if ch == ' ':
gap = 1
else:
if ch == '\n':
gap = 1
else:
if ch == '\t':
gap = 1
else:
if ch == '\r':
gap = 1
else:
if gap == 1 and started == 1:
out = out + ' '
gap = 0
started = 1
out = out + ch
return out
12 test cases ship with it; the first three:
| in | out |
|---|---|
xjav rvc xjav lrszfx 0 | xjav rvc xjav lrszfx 0 |
utmxn ftu utmxn lqwfbv 1 | utmxn ftu utmxn lqwfbv 1 |
lxgvea mwu lxgvea mqapep 2 | lxgvea mwu lxgvea mqapep 2 |
GET https://research.zaiba.cloud/api/v1/programs/collapse_whitespace
POST https://research.zaiba.cloud/api/v1/programs/collapse_whitespace/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/collapse_whitespace/code
# 200 · text/plain · the tool as one Python file, written by the library's authors