Combinatorics.jl icon indicating copy to clipboard operation
Combinatorics.jl copied to clipboard

A combinatorics library for Julia

Results 72 Combinatorics.jl issues
Sort by recently updated
recently updated
newest added

I have the following code that calculates the `hooklength` of a partition. I'll put in a PR when I get time: ```julia function hooklength(σ::Vector{Int}) ret = 1 m = length(σ)...

Hi, I forgot to check whether anyone had implemented integer partitions in Julia and so implemented my own using an adaptation of http://jeromekelleher.net/generating-integer-partitions.html. For me, it's a lot quicker than...

A user on stack overflow asked about whether Julia's `partitions` function could compute [multisets](http://stackoverflow.com/questions/37296557/re-partitions/37312100). It can't, and shouldn't. But a `multisets(n, k)` iterator might actually be useful in some cases....

I needed to sample the nth lexicographic combination of from a collection rather than nth permutation for some internal projects. I'm wondering if there's interest to have this functionality as...

I noticed that `permutations` is much less efficient than the more general `multiset_permutations` when they are both applied to a collection with unique elements: ```julia julia> collect(permutations(1:8)) == collect(multiset_permutations(1:8, 8))...

Add a function to generate all derangements: ```julia julia> map(join, derangements("abbac")) 4-element Vector{String}: "baacb" "bacba" "bcaba" "caabb" ```

Use in-place operations from `Base.GMP.MPZ` to reduce allocations. With this change I get a *massive speed-up*, for instance I pass from ```text julia> @benchmark factorial(big"1000", big"500") BenchmarkTools.Trial: 10000 samples with...

This PR changes the implementation of `derangement`, hence also `subfactorial`, to use the recursive formula `!n = (n-1) * (!(n-1) + !(n-2))` presented [here](https://en.wikipedia.org/wiki/Derangement#Counting_derangements). For values such as `subfactorial(100)` I...

Hi! I"d like to reproduce next Mathematica functions on Julia: [Tuples ](https://reference.wolfram.com/language/ref/Tuples.html) and [Outer ](https://reference.wolfram.com/language/ref/Outer.html) Is it possible with your package, or may be I can add to it?

Use `@inline` on iterate method of Combinations to avoid allocations when creating return tuple Closes #147