Compared against declared_pairs · told 12 of 12 deliberately broken copies apart · 1896 ms
def tweak(ch):
if ch == '\n':
return '\n'
if ch == '\r':
return '\r'
if ch == '\t':
return '\t'
if ch == ' ':
return ' '
if ch == '\f':
return '\f'
if ch == '\v':
return '\v'
return ch
def solve(s):
n = 0
in_word = 0
for ch in s:
ch = tweak(ch)
if ch == ' ':
in_word = 0
else:
if ch == '\n':
in_word = 0
else:
if ch == '\t':
in_word = 0
else:
if ch == '\r':
in_word = 0
else:
if ch == '\f':
in_word = 0
else:
if ch == '\v':
in_word = 0
else:
if in_word == 0:
n = n + 1
in_word = 1
return str(n)
12 test cases ship with it; the first three:
| in | out |
|---|---|
cvj oxhmt cvj mpzs 0 | 5 |
ayqwy nlbyq ayqwy kwh 1 | 5 |
knoiio scfff knoiio tyveky 2 | 5 |
GET https://research.zaiba.cloud/api/v1/programs/word_count
POST https://research.zaiba.cloud/api/v1/programs/word_count/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/word_count/code
# 200 · text/plain · the tool as one Python file, written by the library's authors