Initial upload

This commit is contained in:
2022-08-24 14:28:45 +02:00
parent c67653ddee
commit 57bc7b0289
370 changed files with 18479 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
function encode(s)
ch = nothing
cnt = 1
result = ""
for c s
if ch nothing
ch = c
continue
end
if ch == c
cnt += 1
else
result *= cnt > 1 ? "$cnt$ch" : "$ch"
ch = c
cnt = 1
end
end
if ch nothing
result *= cnt > 1 ? "$cnt$ch" : "$ch"
end
result
end
function decode(s)
items = collect(eachmatch(r"(\d+)?(.)", s))
result = ""
for item items
cnt = parse(Int, (item[1] nothing) ? "1" : item[1])
result *= item[2]^cnt
end
result
end