Compared against declared_pairs · told 12 of 12 deliberately broken copies apart · 1894 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 code(ch):
if ch == '\n':
return 10
if ch == '\r':
return 13
if ch == '\t':
return 9
chars = ' !"#' + "%&'()*+,-./0" + '123456789:;' + '<' + '=' + '>' + '?@' + 'ABCDEFGHIJKLMNOP' + 'QRSTUVWXYZ[\\]^_`' + 'abcdefghijklmnop' + 'qrstuvwxyz{|}~'
i = 0
n = len(chars)
while i < n:
if chars[i] == ch:
if i < 4:
return 32 + i
return 33 + i
i = i + 1
return -1
def solve(s):
digits = '0123456789' + 'abcdef'
out = ''
for ch in s:
n = code(tweak(ch))
if n < 0:
n = n
else:
out = out + digits[n // 16] + digits[n % 16]
return out
12 test cases ship with it; the first three:
| in | out |
|---|---|
orgw jdqc orgw tqlbc 0 | 6f726777206a6471630a6f726777202074716c62632030 |
sih snnv sih rwnsua 1 | 73696820736e6e760a736968202072776e7375612031 |
zqv iwprat zqv ioxmr 2 | 7a7176206977707261740a7a71762020696f786d722032 |
GET https://research.zaiba.cloud/api/v1/programs/hex_encode
POST https://research.zaiba.cloud/api/v1/programs/hex_encode/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/hex_encode/code
# 200 · text/plain · the tool as one Python file, written by the library's authors