Questions tagged [combinatorics]

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

13 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
73 views

A straightforward method for computing the Binomial probability mass function

I've been writing up code to test an alternate way of calculating the Binomial probability mass function. The Binomial random variable is the number of heads out of N coin tosses with coins that have ...
784 views

Finding combination of coins that can produce a given sum

This function is checking, whether it has enough money in a list called self.deviceMoney to make change. It works exactly the way I want, but only in case where ...
70 views

Determining if two packs are permutations of each other during compile-time

Often we need to find out if two tuples, or two packs in general, are the same as each other up to permutation. If there are no repeat types, then implementing ...
293 views

Recursively generate combinations while using Boost Coroutines

I've tried out implementing a combination generator using boost coroutines. It accepts an array of possible values and generates one array at a time for each combination. As a limitation, it only ...
2k views

Brute force shortest path in Java

I had to ask myself a couple years ago: before Edsger Dijkstra invented his famous shortest path algorithm, how brute force approach would seem. Below is my version. It's super slow, but I find it ...
420 views

Python knapsack program

I have this data for the knapsack problem: List of product prices = MENU Most popular product count = MOST_POPULAR_COCKTAIL ...
23 views

Interleave two lists, preserving the order of elements in their original list

I need to write an OCaml program that return all possible zip of two lists together while preserving the order of the element in each list. For example, if we zip the lists [1;2] and [3;4], we get [[1;...
57 views

Calculate and plot expected value involving summations and products

I wrote a code to calculate a series of summations and products for a maths assignment I'm doing. The equation is shown below. E(\sigma)=[1-(P(\text{$1^{st}$ rejects}) \times P(\text{$2^{nd}$ ...
3k views

Solution to King Kohima problem in Python

King Kohima problem: King Kohima has reserved a new exclusive street for his executive class employees where they can build their homes. He has assigned you to plan that street. You have to ...
51 views

itertools.produce reduced and filtered

I need to generate list of all allowable test combination values of of actor, action and ...
222 views

Permutation of a given set

A simple aspect of brute forcing certain problems is that you may have to do a large numbers of tasks in large numbers of possible orders, as such an algorithm for calculating all these possible ...