Problem 594. "Look and say" sequence
What's the next number in this sequence?
- [0]
- [1 0]
- [1 1 1 0]
- [3 1 1 0]
- [1 3 2 1 1 0]
This a variant on the well-known "look and say" or Morris sequence, where each new iteration is made up by 'saying' the number of numbers you see. That last line is "one 3; then two 1s; then one 0".
Create a function that returns the next element of this sequence, given a vector as a starting seed..
Solution Stats
Problem Comments
-
4 Comments
Test suite case 3 seems to be incorrect.
yeah, test case 3 should be [1 1 2 3 1 1 1 5 2 2] by my calculation
Sorry about that. Cut and paste fail.
Test case 3 is still incorrect.
Solution Comments
Show commentsProblem Recent Solvers205
Suggested Problems
-
4063 Solvers
-
Return the 3n+1 sequence for n
8257 Solvers
-
Find the two most distant points
2826 Solvers
-
Test if a Number is a Palindrome without using any String Operations
230 Solvers
-
Remove the two elements next to NaN value
646 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!