June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
10
Task/Run-length-encoding/Julia/run-length-encoding.julia
Normal file
10
Task/Run-length-encoding/Julia/run-length-encoding.julia
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using IterTools
|
||||
|
||||
encode(str::String) = collect((length(g), first(g)) for g in groupby(first, str))
|
||||
decode(cod::Vector) = join(repeat("$l", n) for (n, l) in cod)
|
||||
|
||||
for original in ["aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa", "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"]
|
||||
encoded = encode(original)
|
||||
decoded = decode(encoded)
|
||||
println("Original: $original\n -> encoded: $encoded\n -> decoded: $decoded")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue