Problem 590. Greed is good - Simple partition P[n].

Find a simple partition P[n]. E.g. P[10] = 4 + 3 + 2 + 1.

  1. There are many solutions, compute just one set.
  2. Don't repeat numbers.
  3. Be Greedy ;-)
  4. To check against trivial solutions, E.g. [x-k, k] etc; but I'll provide you with one to start.
  5. 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

57.14% Correct | 42.86% Incorrect
Last solution submitted on May 09, 2016
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more