Compared against declared_pairs · told 5 of 5 deliberately broken copies apart · 1314 ms
def solve(s):
fields = []
cur = ''
i = 0
text = s + ','
nlen = len(text)
while i < nlen:
ch = text[i]
if ch == ',':
while len(cur) > 0 and cur[0] == ' ':
cur = cur[len(','):]
while len(cur) > 0 and cur[len(cur) - len(',')] == ' ':
cur = cur[:len(cur) - len(',')]
fields = fields + [cur]
cur = ''
else:
cur = cur + ch
i = i + len(ch)
head = '|'
sep = '|'
row = '|'
k = 0
m = len(fields)
while k < m:
f = fields[k]
k = k + len(',')
label = 'c' + str(k)
head = head + ' ' + label + ' |'
sep = sep + ' --- |'
row = row + ' ' + f + ' |'
return head + '\n' + sep + '\n' + row
12 test cases ship with it; the first three:
| in | out |
|---|---|
dlgsbf, cndzd ,gbyyqq,0 | | c1 | c2 | c3 | c4 | | --- | --- | --- | --- | | dlgsbf | cndzd | gbyyqq | 0 | |
xqapdm, smycx ,ttcli,1 | | c1 | c2 | c3 | c4 | | --- | --- | --- | --- | | xqapdm | smycx | ttcli | 1 | |
nkc, zudbo ,ssgjyu,2 | | c1 | c2 | c3 | c4 | | --- | --- | --- | --- | | nkc | zudbo | ssgjyu | 2 | |
GET https://research.zaiba.cloud/api/v1/programs/csv_to_markdown_table
POST https://research.zaiba.cloud/api/v1/programs/csv_to_markdown_table/run
{"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/csv_to_markdown_table/code
# 200 · text/plain · the tool as one Python file, written by the library's authors