tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
13
Task/Run-length-encoding/D/run-length-encoding-1.d
Normal file
13
Task/Run-length-encoding/D/run-length-encoding-1.d
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import std.algorithm, std.array;
|
||||
|
||||
alias encode = group;
|
||||
|
||||
auto decode(Group!("a == b", string) enc) {
|
||||
return enc.map!(t => [t[0]].replicate(t[1])).join;
|
||||
}
|
||||
|
||||
void main() {
|
||||
immutable s = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWW" ~
|
||||
"WWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW";
|
||||
assert(s.encode.decode.equal(s));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue