See my function "seqle" on FileExchange. It may not be as compact, but it's easy to use and both encodes and decodes.
The problem statement would have been clearer if the principle of RLE had been explained with an encoding example first. Alternatively, it would have been useful to explicitly mention that the data in vector x is being read pairwise.
easy
useful challenge
ugly but more fun than loops!
note: repelem did not exist back when this problem was created
not limited to 1-9
Number of 1s in the Binary Representation of a Number
356 Solvers
3979 Solvers
Project Euler: Problem 7, Nth prime
523 Solvers
Back to basics 25 - Valid variable names
293 Solvers
420 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!