Finding all combination of portions of a number.

  • Context: Undergrad 
  • Thread starter Thread starter lucasfeijo
  • Start date Start date
  • Tags Tags
    Combination
Click For Summary
SUMMARY

The discussion focuses on finding all combinations of portions that sum up to a specific number, exemplified by the number 5, which can be expressed in six distinct ways. Participants suggest using the concept of "partition numbers" to approach the problem, emphasizing the importance of visualizing the number as a series of ones and considering different bracket placements. The user seeks programming assistance to implement this solution, referencing a code snippet on Ideone that lacks clarity.

PREREQUISITES
  • Understanding of partition numbers in combinatorial mathematics
  • Familiarity with recursive programming techniques
  • Basic knowledge of Python or similar programming languages
  • Experience with algorithm optimization strategies
NEXT STEPS
  • Research the mathematical theory behind partition numbers
  • Learn about recursive algorithms for generating combinations
  • Explore Python libraries for combinatorial functions, such as itertools
  • Study dynamic programming techniques to optimize partition calculations
USEFUL FOR

Mathematicians, computer scientists, and programmers interested in combinatorial algorithms and those looking to implement efficient solutions for partitioning numbers.

lucasfeijo
Messages
2
Reaction score
0
Is there a way to define in how many ways can I form a number by it's portions?

e.g: the number 5 has 6 ways:
1+1+1+1+1
2+1+1+1
2+3
2+2+1
3+1+1
4+1​

I was trying to program that and would appreciate any help!

Thanks.
 
Physics news on Phys.org
This not-commented code is really hard to understand, could you explain the solution please?

Thanks
 
Also search web for 'partition numbers'
 
The basic idea is, think of your number as 1+1+1+... and think of all the different ways to put brackets in this expression.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
966
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
762
  • · Replies 21 ·
Replies
21
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 26 ·
Replies
26
Views
967
  • · Replies 4 ·
Replies
4
Views
2K