We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [combinatorics]

Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures.

Filter by
Sorted by
Tagged with
10
votes
2answers
7k views

Print all permutations with repetition of characters

Given a string of length n, print all permutation of the given string. Repetition of characters is allowed. Print these permutations in lexicographically sorted order Examples: Input: AB ...
3
votes
1answer
6k views

Generating all subsets of a given set

I am learning Java Collections Framework. Can someone look at this code for generating all subsets of a given set and tell me any issues with it. ...
4
votes
1answer
335 views

compression condition permutation

I have 16 permutations each with 104 variables using the standard alphabet. The 104 variable permutation is selected based off of compression complexity. This is one example of the pattern I am able ...
6
votes
1answer
9k views

Generating words based on a list of letters

I wrote a program to take a list of letters and from every permutation of them and check that against the dictionary and print out valid words. The constraints are that there is a control letter ...
7
votes
1answer
2k views

Pairwise Combinations Generator

Below is an algorithm to generate all pairwise combinations for a set of random variables. See here for an explanation of what constitutes a minimal all-pairs set. The algorithm below works but I feel ...
2
votes
2answers
3k views

Printing nth bell number

Bell number \$B(n)\$ is defined as the number of ways of splitting \$n\$ into any number of parts, also defined as the sum of previous \$n\$ Stirling numbers of second kind. Here is a snippet of ...
8
votes
2answers
30k views

Permutations of a list of numbers

I have written a program to find all the possible permutations of a given list of items. This precisely means that my program prints all possible P(n,r) values for r=0 to n. ...
41
votes
1answer
2k views

Finding minimum scalar product using ST Monad

Inspired by a Stack Overflow question, I decided to practice my Haskell by taking a crack at the Google Code Jam's Minimum Scalar Product problem: Given two vectors \$\mathbf{v_1}=(x_1,x_2,\ldots,...
5
votes
1answer
1k views

Enumerate k-combinations in Clojure (P26 from 99 problems)

I've been playing with Clojure for the last few evenings, going through the well known 99 problems (I'm using a set adapted for Scala). Problem 26 Given a set S and a no. of items K, returns ...
2
votes
3answers
914 views

Permutations Finder Help Number 2

Previous question: Java application for finding permutations efficiently> I have changed quite a bit of code, and need some more reviews. ...
73
votes
9answers
107k views

Generating all combinations of an array

I'm generating all combinations of an array, so for instance, ["a", "b", "c", "d"] will generate: ...
8
votes
1answer
748 views

Java application for finding permutations efficiently

I am an eighth grader with a school project of creating and application in Java that returns the total permutations of two given numbers. It needs to be light and efficient, for later deployment on a ...
0
votes
1answer
472 views

Finding columns of a matrix that are the same for combinations of events

How I can change this multi-loop to reduce the computation time? A is a matrix (5 × 10000) where the fifth line contains values between 1 and 50 corresponding to ...
2
votes
1answer
334 views

Organizing matches between sports teams

How could I improve this algorithm? The goal is to organize matches between sport teams such that: Each team affront each other A minimum number of team should start a match after just finishing one ...
17
votes
3answers
14k views

Finding all k-subset partitions

The following code generates all \$k\$-subsets of a given array. A \$k\$-subset of set \$X\$ is a partition of all the elements in \$X\$ into \$k\$ non-empty subsets. Thus, for ...
5
votes
2answers
8k views

Python generator function that yields combinations of elements in a sequence sorted by subset order

In Python, itertools.combinations yields combinations of elements in a sequence sorted by lexicographical order. In the course of solving certain math problems, I ...
4
votes
3answers
3k views

Generating permutations and combinations

How can this code be improved? ...
6
votes
2answers
12k views

Splitting an array of numbers into all possible combinations

This takes an array of numbers then splits it into all possible combinations of the number array of size 4 then in another array puts the leftovers. As I want to take the difference in averages of ...