A catalog tool: listed by construction. A tool built for a request carries the report of its own admission here.
def lines(s):
out = []
cur = ''
for ch in s:
if ch == '\n':
out = out + [cur]
cur = ''
else:
cur = cur + ch
if cur != '':
out = out + [cur]
return out
def joinl(xs):
out = ''
first = True
for x in xs:
if first:
out = out + x
first = False
else:
out = out + '\n' + x
return out
lo = {'A':'a','B':'b','C':'c','D':'d','E':'e','F':'f','G':'g','H':'h','I':'i','J':'j','K':'k','L':'l','M':'m','N':'n','O':'o','P':'p','Q':'q','R':'r','S':'s','T':'t','U':'u','V':'v','W':'w','X':'x','Y':'y','Z':'z'}
def low(x):
out = ''
for ch in x:
if ch in lo:
out = out + lo[ch]
else:
out = out + ch
return out
def solve(s):
ls = lines(s)
pairs = sorted([(low(l), i, l) for (i, l) in enumerate(ls)])
out = []
for (k, i, l) in pairs:
out = out + [l]
return joinl(out)
8 test cases ship with it; the first three:
| in | out |
|---|---|
Eab hufye Dqvm eab0 | Eab eab0 hufye Dqvm |
Wxz piuyaz Ypsn wxz1 | piuyaz Ypsn Wxz wxz1 |
Vgdzcx pyq Xrval vgdzcx2 | pyq Xrval Vgdzcx vgdzcx2 |
GET https://research.zaiba.cloud/api/v1/programs/lines_sorted_ci
POST https://research.zaiba.cloud/api/v1/programs/lines_sorted_ci/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/lines_sorted_ci/code
# 200 · text/plain · the tool as one Python file, written by the library's authors