Problem 2360. Fill an array given a sum and array length values
Fill an array with random numbers so that their sum and array length will be equal to the given values as input. Function will generate 1 value at a time (not whole array at once)
Example
Let's say you are asked to fill 5 elements (n = 5) in an empty array where summation of their elements (sum_up = 4) should be 4. Then the function will be invoked 5 times in the test suite, and your function supposed to check the array being constructed (sum_array) and provide 1 element each time.
Solution Stats
Problem Comments
- 
		1 Comment
		Ashan Peiris
    	on 12 Jun 2014
	
	
  	Tricky problem !!
Solution Comments
Show commentsProblem Recent Solvers17
Suggested Problems
- 
         Back to basics 16 - byte order 195 Solvers 
- 
         Back to basics 17 - white space 274 Solvers 
- 
         Determine if input is a perfect number 248 Solvers 
- 
         07 - Common functions and indexing 1 445 Solvers 
- 
         Side of an equilateral triangle 6686 Solvers 
More from this Author6
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!