Problem 60751. List the partitions of an integer
Solution Stats
Problem Comments
-
6 Comments
61, why are you in the test suite... I have a straightforward solution, but it takes 63 seconds on my machine for 61, and times out on Cody too.
My solution takes about 10 seconds on my laptop and 6 seconds on Cody for n = 61. I'm looking forward to seeing solutions from the community, which are usually cleverer and faster than mine.
Thanks, Chris. I took another look and managed to get a faster version that now takes ~5 seconds on my machine for 61.
Chris - This problem is beautifully written! but I need to point out that the example in paragraph 4 for the partitions of the number 5 contains 2 incorrect partitions. The each add up to more than 5. The partitions of 5 given in the last line are, however, correct.
Yikes. Thanks, William!
If we were on the quiz site Sporcle, writing code that correctly computes the 8,118,264 partitions of 75 but mangling simple arithmetic would be an example of Sporclitis. During a quiz involving world capitals starting with W, I wrote down Warsaw, Wellington, and Windhoek but could not come up with the fourth--the capital of my own country.
Solution Comments
Show commentsProblem Recent Solvers4
Suggested Problems
-
List the partitions of an integer
4 Solvers
More from this Author279
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!