write a function
func(small_array, size_bigarray, divisor, index_where_small_array_begins, size_smallarray)
The function does the following:
big array with
size bigarray. (you don't have the array explicity)
It is filled with
zeros. Except from
index_where_small_array_begins the values of the
big_array are identically with
small_array contains only positive numbers. (not zero)
small_array is a part of
big_array. (you can assume it fits, that means
Now split the
mini_arrays of size
divisor is not a divisor of
size_bigarray, the last array is smaller)
size_bigarray = 10,
divisor = 3, then you have four arrays of size: 3, 3, 3, 1)
For each of the
mini_array you add the values together, call it
Print out an array with
sum_of_the_miniarray for all
miniarrays for which the
sum_of_the_miniarray is nonzero. (You can conclude that from
small_array = [1,2,3] index_where_small_array_begins = 4 size_bigarray = 8 divisor = 3
then big_array would be:
big_array = [0,0,0,0,1,2,3,0]
the mini arrays would be
[0,0,0] [0,1,2] [3,0]
the sums would be
0 3 3
But you only output
[3,3] because the first one is zero.
You are not allowed to construct the big array explicitly!
You are not allowed to construct the mini arrays explicitly!
That means you have to get the computation directly from the small_array!
Fewest characters wins!