Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Run-length-encoding/11l/run-length-encoding.11l
Normal file
24
Task/Run-length-encoding/11l/run-length-encoding.11l
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
F encode(input_string)
|
||||
V count = 1
|
||||
V prev = Char("\0")
|
||||
[(Char, Int)] lst
|
||||
L(character) input_string
|
||||
I character != prev
|
||||
I prev != Char("\0")
|
||||
lst.append((prev, count))
|
||||
count = 1
|
||||
prev = character
|
||||
E
|
||||
count++
|
||||
lst.append((input_string.last, count))
|
||||
R lst
|
||||
|
||||
F decode(lst)
|
||||
V q = ‘’
|
||||
L(character, count) lst
|
||||
q ‘’= character * count
|
||||
R q
|
||||
|
||||
V value = encode(‘aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa’)
|
||||
print(‘Encoded value is ’value.map(v -> String(v[1])‘’v[0]))
|
||||
print(‘Decoded value is ’decode(value))
|
||||
Loading…
Add table
Add a link
Reference in a new issue