Problem 590. Greed is good - Simple partition P[n].
Find a simple partition P[n]. E.g. P[10] = 4 + 3 + 2 + 1.
- There are many solutions, compute just one set.
- Don't repeat numbers.
- Be Greedy ;-)
- To check against trivial solutions, E.g. [x-k, k] etc; but I'll provide you with one to start.
- Show me how you write the whole solution.
Bonus points if you solve the general problem of producing all unique partitions of [n].
Solution Stats
Problem Comments
- 
		1 Comment
		Rafael S.T. Vieira
    	on 3 Oct 2020
	
	
  	Maybe you should say that the partition must have size greater than ceil(log2(x)/2)), since you test this at the test suite. The total number of partitions that a number has may be huge, even if we consider only unique sets (ignoring the order): a sum of binomial coefficients from 1 to the number-1 (where there is only one possible set of ones).
Solution Comments
Show commentsProblem Recent Solvers29
Suggested Problems
- 
         Find all elements less than 0 or greater than 10 and replace them with NaN 15689 Solvers 
- 
         
         2505 Solvers 
- 
         
         1900 Solvers 
- 
         
         566 Solvers 
- 
         
         252 Solvers 
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!