10 lines
275 B
R
10 lines
275 B
R
|
|
runlengthencoding <- function(x)
|
||
|
|
{
|
||
|
|
splitx <- unlist(strsplit(input, ""))
|
||
|
|
rlex <- rle(splitx)
|
||
|
|
paste(with(rlex, as.vector(rbind(lengths, values))), collapse="")
|
||
|
|
}
|
||
|
|
|
||
|
|
input <- "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
|
||
|
|
runlengthencoding(input)
|