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 finally learned how to make a pull request, based on this [issue](https://github.com/JuliaMath/Combinatorics.jl/issues/95) Here I copied in the code that rdeits originally wrote [here](https://discourse.julialang.org/t/slow-permutations/39427/4) I also updated the tests to...

I know that `binomial` is in base (after searching way too long), but someone looking for it might naturally come here, or might know "n choose k" but not the...

I thought this addition might be handy ``` combinations(a, T::AbstractVector{ collect(combinations(1:5, 2:3)) 20-element Vector{Vector{Int64}}: [1, 2] [1, 3] [1, 4] [1, 5] ⋮ [2, 3, 4] [2, 3, 5] [2,...

to my full surprise the `combinations` function cannot deal with Sets directly. As Sets support `iterate` and `length`, I think this is a bug ``` julia> collect(combinations(Set([1,2,3,4]), 2)) ERROR: MethodError:...

I believe it would be useful to add a method to generate permutations with repetitions, so that, for example julia> collect(with_replacement_permutations(1:2, 2)) 4-element Vector{Vector{Int64}}: [1, 1] [1, 2] [2, 1]...

The documentation for `multiset_permutations` does not seem to be auto-consistent: > multiset_permutations(m, f, t) > > Generate all permutations of size `t` from an array `a` with possibly duplicated elements....

Hi there! For one of my projects I wrote a small implementation of [Heap's algorithm](https://en.wikipedia.org/wiki/Heap%27s_algorithm), which iterates through all permutations of an array by shuffling its elements in-place. It does...

Here are some timings for comparison. before ```julia julia> @btime collect(partitions(10)); 3.995 μs (85 allocations: 6.12 KiB) julia> @btime collect(partitions(30)); 772.853 μs (11210 allocations: 1017.45 KiB) julia> @btime collect(partitions(50)); 35.195...

surprising that the empty combination is not included also surprising it's not called "subsets"

Stirling numbers of the second kind are always nonnegative and yet: ``` julia> stirlings2(26,10) -5247188700862703611 ``` The same issue plagues `stirlings1`. We have ``` julia> stirlings1(26,10) 9107464261356742080 ``` but the...