Problem 57939. Sequence Vectorization - II
This is the second part to the question - Sequence Vectorization - I
Given an array of Natural numbers, N, return the sequence - horizontal concatenation of (1:k) for k - N(1), N(2), ... N(end)
%Example 1
N=[2 5 3];
Out=[1 2, 1 2 3 4 5, 1 2 3];
%Example 2
N=[3 4];
Out=[1 2 3, 1 2 3 4];
%Example 2
N=[11 1 5];
Out=[1 2 3 4 5 6 7 8 9 10 11, 1, 1 2 3 4 5];
As the question deals with vectors, the solutions must be vectorized as well. Check the test suite for banned functions.
Solution Stats
Problem Comments
-
3 Comments
William
on 5 Apr 2023
Am I missing something?
In test 7, there is a sequence 1:7 that seems to come out of nowhere.
Also, in test 10, there are 2 issues: 1) line 3 is missing a parenthesis, and 2) the array t has only 25 elements, but is evaluated for a random index between 1 and 100.
Dyuman Joshi
on 5 Apr 2023
Apologies William, the reference answer to test case #7 was incorrect and as you mentioned test case #10 had issues.
I have corrected the errors, and your solution has been rescored. Please rate the question!
Christian Schröder
on 5 Apr 2023
Good problems!
Solution Comments
Show commentsProblem Recent Solvers7
Suggested Problems
-
600 Solvers
-
Make a random, non-repeating vector.
9152 Solvers
-
405 Solvers
-
650 Solvers
-
Sum of the Multiplication of Vectors
266 Solvers
More from this Author31
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!