Given a "counting sequence" vector x, construct the original sequence y.
A counting sequence is formed by "counting" the entries in a given sequence. This is sometimes called run-length encoding.
For example, the sequence
x = 2, 5, 1, 2, 4, 1, 1, 3
can be read as
Two 5's, one 2, four 1's, one 3
which translates to
y = 5, 5, 2, 1, 1, 1, 1, 3
So y is the reconstructed vector that corresponds to the counting sequence x.
For this problem, all elements in the sequences x and y will be in the range from 1 to 9.
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
Find the sum of all the numbers of the input vector
27020 Solvers
7630 Solvers
2837 Solvers
598 Solvers
Number of 1s in a binary string
1416 Solvers