Questions tagged [integer-partition]

In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers. Two sums that differ only in the order of their summands are considered the same partition. (If order matters, the sum becomes a composition.)

In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers. Two sums that differ only in the order of their summands are considered the same partition. (If order matters, the sum becomes a composition.)

References:

47 questions
2
votes
1 answer

Finding A List of All Combinations of 6 Numbers That Add up to 10

So I've seen similar versions of this question asked before (Getting all combinations which sum up to 100 using R) but I'm struggling to find a way to figure out what I need to run specifically. I'm trying to create a list in R of all the different…
2
votes
1 answer

Rank and unrank integer partition with k parts

For positive integers n and k, let a "k-partition of n" be a sorted list of k distinct positive integers that add up to n, and let the "rank" of a given k-partition of n be its position in the sorted list of all of these lists in lexicographic…
1
vote
1 answer

Number of integer partitioning into exactly k parts (calculating for large integer )

Following this thread python-integer-partitioning-with-given-k-partitions I want to find the number of such partitions (where the minimum part is equal to 1), but the following solution (in the thread and many other threads) gives the exact…
linuxbeginner
  • 39
  • 1
  • 7
1
vote
0 answers

Partitioning algorithm for a list of lists in Python

I'm working on a music related problem and I need some help with a crucial step. I have four lists of numbers from 0 to 11 (including). These lists are to be thought of as vertically aligned. I want to partition those 4 lists into 4 blocks, each…
1
vote
0 answers

Randomly sampling integer partitions (without restriction on number of parts)

I have an integer N and I wish to generate one of its possible partitions uniformly at random. For example, N=5 has 7 partitions: (5) - K=1 part (4, 1) - K=2 parts (3, 2) - K=2 parts (3, 1, 1) - K=3 parts (2, 2, 1) - K=3 parts (2, 1, 1, 1) - K=4…
lucasvb
  • 11
  • 1
1
vote
0 answers

Turning a Python generator into a C function

I am trying to translate a Python generator into a function in C. If it's worth mentioning, I'm trying to write a program that partitions an integer n, into l distinct parts. I believe that I've got most of it working, I do not kow how to implement…
murage kibicho
  • 546
  • 5
  • 14
1
vote
2 answers

Algorithm to find some rows from a matrix, whose sum is equal to a given row

For example, here is a matrix: [1, 0, 0, 0], [1, 1, 0, 0], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1], I want to find some rows, whose sum is equal to [4, 3, 2, 1]. The expected answer is rows: {0,1,3,4}. Because: [1, 0, 0, 0] + [1, 1, 0, 0] + [1, 1,…
1
vote
0 answers

Number of ways to get sum of number(Integer Partition) using recursion or other methods

Question from codewars https://www.codewars.com/kata/52ec24228a515e620b0005ef/python In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers. Two…
Ayam Chan
  • 75
  • 7
1
vote
1 answer

Count integer partitions with k parts when partition elements given

I want to count the integer partitions of n with k partition elements. The possible partition elements are defined through a given vector v with distinct elements. Partition elements can be choosen more than once. How Can i do this? Optimal without…
1
vote
1 answer

Reconstruct bitsequence from a Set of properties

I want to reconstruct a Bitsequence from given Sets of ones, the number x and other properties. In the bitsequence the first bit has the value 1, second the value 2, the third is 3. etc. For example i have following properties: x=15 ( sum of all…
1
vote
1 answer

How to index doubly restricted integer partitions?

When enumerating all partitions of a positive integer with the following 2 restrictions: the size of each partition is always PartitionSize all elements of these partitions are less than or equal to MaxVal, and greater than zero. ...I am faced…
George Robinson
  • 1,500
  • 9
  • 21
1
vote
0 answers

Restricted integer partitions in Python

I want to find out how many ways there are to make 500 using only 1, 2, 5, 10, 20, 50, 100, and 200. I understand that there exist greedy algorithms etc that can solve this type of question, but I want to be able to do it the following way: The…
tsojtc
  • 69
  • 7
1
vote
1 answer

Number of Integer Composition with the number which is in a specific list

Each positive integer n has 2^(n−1) distinct compositions. what If I want the number of composition which is only have specific number which is in my list: for example composition of 4 is 4 3 1 1 3 2 2 2 1 1 1 2 1 1 1 2 1 1 1 1 but if I want the…
Geo-7
  • 127
  • 9
1
vote
1 answer

Combining permutation groups

I am developing a probability analysis program for a board game. As part of an algorithm* I need to calculate the possible permutations of partitions of a number (plus some padding), such that all partition components cannot occupy any position that…
Tom
  • 11
  • 3
1
vote
1 answer

Different ways to calculate number

I need to write a function that will return the number of ways in which can be n (n is a natural number) written as the sum of natural numbers. For example: 4 can be written as 1+1+1+1, 1+1+2, 2+2, 3+1 and 4. I have written a function that returns…
koshy6252
  • 75
  • 1
  • 6