The combinatorics tag has no wiki summary.
1
vote
0answers
30 views
How to make python knapsack program faster
I have knapsack problem:
I have data:
List of product prices = MENU
Most popluar product count = MOST_POPULAR_COCKTAIL
Knapsack price = CASH
Knapsack length = CHECK_LEN
I need get all knapsack ...
0
votes
2answers
87 views
How make this algorithm faster?
I have python code.
import itertools
from decorators import timer
from settings import MENU, CASH
class Cocktail(object):
def __init__(self, group, name, sell, count=0):
self.group = ...
1
vote
1answer
41 views
Any way to optimize or improve this python combinations/subsets functions?
I believe this is essentially the same method as the itertools.combinations function, but is there any way to make this code more more perfect in terms of speed, code size and readability :
def ...
2
votes
2answers
91 views
multi-recursive replacement function
I wrote a function for creating all possible translations of a source string, based on a multiple translation map. It works, but generates a lot of intermediate maps (see line marked with *). Is there ...
1
vote
2answers
116 views
Discovering words from letters in Clojure (Letterpress Solver)
I created a Letterpress solver that will take a string of letters and return a list of valid words that can be constructer with the provided letters. Not all letters need to be used in each word.
...
5
votes
1answer
339 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 ...
5
votes
1answer
276 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 calls for a function that, given a set S and a no. ...
11
votes
5answers
3k views
Better way to generate all combinations?
I'm generating all combinations of an array, so for instance, ["a", "b", "c", "d"] will generate:
[
"a", "b", "ab", "c", "ac",
"bc", "abc", "d", "ad", "bd",
"abd", "cd", ...
2
votes
1answer
224 views
A combinatorial algorithm
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
...
1
vote
2answers
1k 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 found it useful to write a function, ...