{"id":30495445,"url":"https://github.com/matthias314/smallcombinatorics.jl","last_synced_at":"2025-08-25T00:21:13.263Z","repository":{"id":302341156,"uuid":"1012111873","full_name":"matthias314/SmallCombinatorics.jl","owner":"matthias314","description":"A combinatorics package for Julia based on SmallCollections.jl","archived":false,"fork":false,"pushed_at":"2025-08-06T12:10:59.000Z","size":241,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-06T14:19:38.522Z","etag":null,"topics":["combinatorics"],"latest_commit_sha":null,"homepage":"https://matthias314.github.io/SmallCombinatorics.jl/","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthias314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-01T20:41:02.000Z","updated_at":"2025-08-06T12:11:03.000Z","dependencies_parsed_at":"2025-08-06T14:12:40.469Z","dependency_job_id":"2a82d095-9d23-4b5a-8ca0-4862a84d9660","html_url":"https://github.com/matthias314/SmallCombinatorics.jl","commit_stats":null,"previous_names":["matthias314/smallcombinatorics.jl"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/matthias314/SmallCombinatorics.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias314%2FSmallCombinatorics.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias314%2FSmallCombinatorics.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias314%2FSmallCombinatorics.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias314%2FSmallCombinatorics.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthias314","download_url":"https://codeload.github.com/matthias314/SmallCombinatorics.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias314%2FSmallCombinatorics.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271984184,"owners_count":24853812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["combinatorics"],"created_at":"2025-08-25T00:21:10.772Z","updated_at":"2025-08-25T00:21:13.252Z","avatar_url":"https://github.com/matthias314.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SmallCombinatorics.jl\n\nThis package provides functions for enumerative combinatorics. It was formerly a submodule of\n[SmallCollections.jl](https://github.com/matthias314/SmallCollections.jl).\n\nThe functions in `SmallCombinatorics` are often much faster than their counterparts\nin other combinatorics packages. This is achieved by using the fast, non-allocating\ncontainer types offered by `SmallCollections`. These types have a maximal capacity,\nwhich implies there are bounds on the input parameters of the functions. At present,\nmost bounds are hard-coded. For example, the function `permutations(n::Integer)` can produce\npermutations only for `n ≤ 16`. In contrast, the vector version `permutations(v::SmallVector)`\nhas no restriction on the length of the\n[`SmallVector`](https://matthias314.github.io/SmallCollections.jl/v0.5.0/smallvector/#SmallCollections.SmallVector).\n\nSo far, the list of implemented functions is fairly short, but hopefully it will grow.\nThe full documentation  for `SmallCombinatorics` is available\n[here](https://matthias314.github.io/SmallCombinatorics.jl/).\n\n## Benchmarks\n\nThe following benchmarks were done with Julia 1.11.6, Chairmarks.jl, SmallCombinatorics.jl v0.1.1,\n[Combinatorics.jl](https://github.com/JuliaMath/Combinatorics.jl) 1.0.3\nand [Combinat.jl](https://github.com/jmichel7/Combinat.jl) 0.1.4.\nIn separate tests, GAP and Sage were 2-3 orders of magnitude slower.\n\n### Permutations\n\nLoop over all permutations of `1:9` and add up the image of `1` under each permutation.\nThe iterator returned by\n[`SmallCombinatorics.permutations`](https://matthias314.github.io/SmallCombinatorics.jl/stable/#SmallCombinatorics.permutations)\n yields each permutation as a `SmallVector{16,Int8}`.\n```julia\njulia\u003e n = 9; @b sum(@inbounds(p[1]) for p in SmallCombinatorics.permutations($n))\n683.524 μs\n\njulia\u003e n = 9; @b sum(@inbounds(p[1]) for p in Combinatorics.permutations(1:$n))\n14.171 s (725763 allocs: 44.297 MiB, 0.40% gc time, without a warmup)\n\njulia\u003e n = 9; @b sum(@inbounds(p[1]) for p in Combinat.Permutations($n))\n13.309 ms (725762 allocs: 44.297 MiB, 11.81% gc time)\n```\n\n### Combinations\n\nLoop over all `10`-element subsets of `1:20` and add up the sum of the elements of each subset.\nThe iterator returned by\n[`SmallCombinatorics.combinations`](https://matthias314.github.io/SmallCombinatorics.jl/stable/#SmallCombinatorics.combinations-Tuple{Integer,%20Integer})\nyields each subset as a [`SmallBitSet`](https://matthias314.github.io/SmallCollections.jl/stable/smallbitset/#SmallCollections.SmallBitSet).\n```julia\njulia\u003e n = 20; k = 10; @b sum(first(c) for c in SmallCombinatorics.combinations($n, $k))\n378.624 μs\n\njulia\u003e n = 20; k = 10; @b sum(first(c) for c in Combinatorics.combinations(1:$n, $k))\n9.064 ms (369514 allocs: 25.373 MiB, 6.34% gc time)\n\njulia\u003e n = 20; k = 10; @b sum(first(c) for c in Combinat.Combinations(1:$n, $k))\n7.768 ms (184765 allocs: 19.735 MiB, 2.41% gc time)\n```\n\n### Partitions\n\nLoop over all partitions of `40` and add up the first element of each partition.\nThe iterator returned by\n[`SmallCombinatorics.partitions`](https://matthias314.github.io/SmallCombinatorics.jl/stable/#SmallCombinatorics.partitions)\n yields each permutation as a `SmallVector{64,Int8}`.\n```julia\njulia\u003e n = 40; @b sum(@inbounds(p[1]) for p in SmallCombinatorics.partitions($n))\n141.197 μs\n\njulia\u003e n = 40; @b sum(@inbounds(p[1]) for p in Combinatorics.integer_partitions($n))\n316.759 ms (3304541 allocs: 100.823 MiB, 24.99% gc time, without a warmup)\n\njulia\u003e n = 40; @b sum(@inbounds(p[1]) for p in Combinat.Partitions($n))\n2.596 ms (37340 allocs: 4.366 MiB)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthias314%2Fsmallcombinatorics.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthias314%2Fsmallcombinatorics.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthias314%2Fsmallcombinatorics.jl/lists"}