Problem 1290. A different counting method
Given an array (x) of integers, the "counting" array (y) is showing the number of identical consecutive integers in x in front of the integer itself. For example, if
- x = 1
- y = [1 1],
because there is one "1". If then
- x = [1 1]
- y = [2 1],
because there are now two "1"s. Finally, a more complex example:
- x = [1 2 2 4 4 3 0 0 1]
- y = [1 1 2 2 2 4 1 3 2 0 1 1].
So y gets two elements for each series of identical integers in x. (I hope this problem does not exist already)
Solution Stats
Problem Comments
-
2 Comments
A similar one is here.
http://www.mathworks.com/matlabcentral/cody/problems/40-reverse-run-length-encoder
You didn't restrict yourself to using only 0-9 in your sequence, though.
Same as Problem 55 Counting Sequence.
Solution Comments
Show commentsProblem Recent Solvers46
Suggested Problems
-
1793 Solvers
-
It dseon't mettar waht oedrr the lrettes in a wrod are.
1913 Solvers
-
Increment a number, given its digits
659 Solvers
-
Create a cell array out of a struct
2084 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
542 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!