Cody

Problem 42832. Segmented number sequence

Created by HH in Community

Given a positive integer, n, and a row vector, x, of positive integers, return a row vector, v, which is a sequence of length n of positive integers, beginning with [1 2...], in which integers that are the sums of any x(i) consecutive previous elements are omitted.

For example, if x = [2 3], meaning integers that are sums of any 2 or 3 consecutive previous elements should be omitted, the output would be v = [1 2 4 5 8 10...v(n)], because 3 is the sum of [1 2], 6 is the sum of [2 4], 7 is the sum of [1 2 4], 9 is the sum of [4 5], and so on, up to n elements of v.

If x = 0, integers that are the sums of any 2 or more consecutive previous elements should be omitted.

Solution Stats

77.78% Correct | 22.22% Incorrect
Last solution submitted on Apr 05, 2019

Problem Comments