{"id":33258142,"url":"https://github.com/dpaukov/combinatoricslib3","last_synced_at":"2026-01-16T20:25:20.309Z","repository":{"id":44704451,"uuid":"49861475","full_name":"dpaukov/combinatoricslib3","owner":"dpaukov","description":"Combinatorial objects stream generators for Java.","archived":false,"fork":false,"pushed_at":"2024-02-20T02:00:41.000Z","size":248,"stargazers_count":188,"open_issues_count":4,"forks_count":24,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-11-21T20:04:14.314Z","etag":null,"topics":["cartesian-product","combinations","combinatorics","java-streams","permutation","subsets"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dpaukov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2016-01-18T08:07:15.000Z","updated_at":"2025-10-10T08:14:07.000Z","dependencies_parsed_at":"2024-04-24T11:01:43.777Z","dependency_job_id":"1ec654cb-461f-4143-8da7-0b869790810d","html_url":"https://github.com/dpaukov/combinatoricslib3","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/dpaukov/combinatoricslib3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpaukov%2Fcombinatoricslib3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpaukov%2Fcombinatoricslib3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpaukov%2Fcombinatoricslib3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpaukov%2Fcombinatoricslib3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpaukov","download_url":"https://codeload.github.com/dpaukov/combinatoricslib3/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpaukov%2Fcombinatoricslib3/sbom","scorecard":{"id":354206,"data":{"date":"2025-08-11","repo":{"name":"github.com/dpaukov/combinatoricslib3","commit":"42b8f5d7a6949b6e27b2464f909d7078cb95809a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":1,"reason":"Found 4/30 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/dpaukov/combinatoricslib3/maven.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/dpaukov/combinatoricslib3/maven.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/maven.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T09:08:56.321Z","repository_id":44704451,"created_at":"2025-08-18T09:08:56.322Z","updated_at":"2025-08-18T09:08:56.322Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cartesian-product","combinations","combinatorics","java-streams","permutation","subsets"],"created_at":"2025-11-17T03:00:30.887Z","updated_at":"2026-01-16T20:25:20.270Z","avatar_url":"https://github.com/dpaukov.png","language":"Java","readme":"[![Build Status](https://github.com/dpaukov/combinatoricslib3/actions/workflows/maven.yml/badge.svg)](https://github.com/dpaukov/combinatoricslib3/actions) \n[![Coverage Status](https://coveralls.io/repos/github/dpaukov/combinatoricslib3/badge.svg?branch=master)](https://coveralls.io/github/dpaukov/combinatoricslib3?branch=master)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.dpaukov/combinatoricslib3.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.dpaukov%22%20AND%20a%3A%22combinatoricslib3%22)\n\n```\n     ___                _     _             _             _             __ _ _       _____ \n    / __\\___  _ __ ___ | |__ (_)_ __   __ _| |_ ___  _ __(_) ___ ___   / /(_) |__   |___ / \n   / /  / _ \\| '_ ` _ \\| '_ \\| | '_ \\ / _` | __/ _ \\| '__| |/ __/ __| / / | | '_ \\    |_ \\ \n  / /__| (_) | | | | | | |_) | | | | | (_| | || (_) | |  | | (__\\__ \\/ /__| | |_) |  ___) |\n  \\____/\\___/|_| |_| |_|_.__/|_|_| |_|\\__,_|\\__\\___/|_|  |_|\\___|___/\\____/_|_.__/  |____/ \n```\n\nA combinatorics library for Java.  \n\n## 3.4.0 - the latest stable release version\nThe latest release of the library is [v3.4.0](https://github.com/dpaukov/combinatoricslib3/releases/tag/v3.4.0).\nIt is available through The Maven Central Repository [here](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.dpaukov%22%20AND%20a%3A%22combinatoricslib3%22).\nAdd the following section into your `pom.xml` file.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.dpaukov\u003c/groupId\u003e\n    \u003cartifactId\u003ecombinatoricslib3\u003c/artifactId\u003e\n    \u003cversion\u003e3.4.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Examples\nYou can check out an example project to see how to use the library [combinatoricslib3-example](https://github.com/dpaukov/combinatoricslib3-example)\n\n## 3.4.1 - current version under development\n1. [Simple combinations](#1-simple-combinations)\n2. [Combinations with repetitions](#2-combinations-with-repetitions)\n3. [Simple permutations](#3-simple-permutations)\n4. [Permutations with repetitions](#4-permutations-with-repetitions)\n5. [k-Permutations](#5-k-permutations)\n6. [Subsets](#6-subsets)\n7. [Integer partitions](#7-integer-partitions)\n8. [Cartesian product](#8-cartesian-product)\n\n\n| Description                      | Is Order Important? | Is Repetition Allowed? | Stream  |\n|----------------------------------|:-------------------:|:----------------------:|---------| \n| [Simple combinations](#1-simple-combinations) | No | No | `Generator.combination(...).simple(n).stream()` |\n| [Combinations with repetitions](#2-combinations-with-repetitions) | No | Yes | `Generator.combination(...).multi(n).stream()` |\n| [Simple permutations](#3-simple-permutations) | Yes | No | `Generator.permutation(...).simple().stream()` |\n| [Permutations with repetitions](#4-permutations-with-repetitions) | Yes | Yes | `Generator.permutation(...).withRepetitions(n).stream()` |\n\n\n### 1. Simple combinations\nA simple k-combination of a finite set S is a subset of k distinct elements of S. \nSpecifying a subset does not arrange them in a particular order. As an example, a poker hand can \nbe described as a 5-combination of cards from a 52-card deck: the 5 cards of the hand are all distinct, \nand the order of the cards in the hand does not matter.\n\nLet's generate all 3-combination of the set of 5 colors (red, black, white, green, blue).\n\n```java\n   Generator.combination(\"red\", \"black\", \"white\", \"green\", \"blue\")\n       .simple(3)\n       .stream()\n       .forEach(System.out::println);\n```\nAnd the result of 10 combinations\n```\n   [red, black, white]\n   [red, black, green]\n   [red, black, blue]\n   [red, white, green]\n   [red, white, blue]\n   [red, green, blue]\n   [black, white, green]\n   [black, white, blue]\n   [black, green, blue]\n   [white, green, blue]\n```\n\n### 2. Combinations with repetitions\nA k-multicombination or k-combination with repetition of a finite set S is given by a sequence of \nk not necessarily distinct elements of S, where order is not taken into account.\n\nAs an example. Suppose there are 2 types of fruits (apple and orange) at a grocery store, and you \nwant to buy 3 pieces of fruit. You could select\n- (apple, apple, apple)\n- (apple, apple, orange)\n- (apple, orange, orange)\n- (orange, orange, orange)\n\n```java\n   Generator.combination(\"apple\", \"orange\")\n       .multi(3)\n       .stream()\n       .forEach(System.out::println);\n```\nAnd the result will be:\n```\n   [apple, apple, apple]\n   [apple, apple, orange]\n   [apple, orange, orange]\n   [orange, orange, orange]\n```\n\n### 3. Simple permutations\nA permutation is an ordering of a set in the context of all possible orderings. For example, the set \ncontaining the first three digits, 123, has six permutations: 123, 132, 213, 231, 312, and 321.\n\nThis is an example of the permutations of the 3 string items (apple, orange, cherry):\n\n```java\n   Generator.permutation(\"apple\", \"orange\", \"cherry\")\n       .simple()\n       .stream()\n       .forEach(System.out::println);\n```\n\n```\n   [apple, orange, cherry]\n   [apple, cherry, orange]\n   [cherry, apple, orange]\n   [cherry, orange, apple]\n   [orange, cherry, apple]\n   [orange, apple, cherry]\n```\n\nThis generator can produce the permutations *even if an initial vector has duplicates*. For example, \nall permutations of (1, 1, 2, 2):\n\n```java\n   Generator.permutation(1, 1, 2, 2)\n       .simple()\n       .stream()\n       .forEach(System.out::println);\n```\n\nThe result does not have duplicates. All permutations are distinct by default.\n```\n   [1, 1, 2, 2]\n   [1, 2, 1, 2]\n   [1, 2, 2, 1]\n   [2, 1, 1, 2]\n   [2, 1, 2, 1]\n   [2, 2, 1, 1]\n```\nNotice that we have 6 permutations here instead of 24. If you still need all permutations, \nyou should call method `simple(PermutationGenerator.TreatDuplicatesAs.IDENTICAL)`.\n\n### 4. Permutations with repetitions\nPermutation may have more elements than slots. For example, all possible permutation of `12` \nin three slots are: `111`, `211`, `121`, `221`, `112`, `212`, `122`, and `222`.\n\nLet's generate all possible permutations with repetitions of 3 elements from the set of apple and orange.\n\n```java\n   Generator.permutation(\"apple\", \"orange\")\n        .withRepetitions(3)\n        .stream()\n        .forEach(System.out::println);\n```\n\nAnd the list of all 8 permutations\n\n```\n   [apple, apple, apple]\n   [orange, apple, apple]\n   [apple, orange, apple]\n   [orange, orange, apple]\n   [apple, apple, orange]\n   [orange, apple, orange]\n   [apple, orange, orange]\n   [orange, orange, orange]\n```\n\n### 5. k-Permutations\nYou can generate k-permutations with and without repetitions using the combination and permutation\ngenerators together. For example, 2-permutations without repetitions of the list (1, 2, 3):\n\n```java\n    Generator.combination(1, 2, 3)\n       .simple(2)\n       .stream()\n       .forEach(combination -\u003e Generator.permutation(combination)\n          .simple()\n          .forEach(System.out::println));\n```\nThis will print six 2-permutations of (1, 2, 3):\n```\n   [1, 2]\n   [2, 1]\n   [1, 3]\n   [3, 1]\n   [2, 3]\n   [3, 2]\n```        \n\nSimilarly, you can get 2-Permutations with repetitions of the list (1, 2, 3):  \n```java \n    Generator.combination(1, 2, 3)\n       .multi(2)\n       .stream()\n       .forEach(combination -\u003e Generator.permutation(combination)\n           .simple()\n           .forEach(System.out::println));\n```\nThis will print all nine 2-permutations of (1, 2, 3):\n```\n   [1, 1]\n   [1, 2]\n   [2, 1]\n   [1, 3]\n   [3, 1]\n   [2, 2]\n   [2, 3]\n   [3, 2]\n   [3, 3]\n```        \n\n### 6. Subsets\nA set `A` is a subset of a set `B` if `A` is \"contained\" inside `B`. `A` and `B` may coincide. \nThe relationship of one set being a subset of another is called inclusion or sometimes containment.\n\nExamples:\n\nThe set `(1, 2)` is a proper subset of `(1, 2, 3)`.\nAny set is a subset of itself, but not a proper subset.\nThe empty set, denoted by ∅, is also a subset of any given set `X`.\nAll subsets of `(1, 2, 3)` are:\n\n- ()\n- (1)\n- (2)\n- (1, 2)\n- (3)\n- (1, 3)\n- (2, 3)\n- (1, 2, 3)\n\nHere is a piece of code that generates all possible subsets of (one, two, three)\n\n```java\n   Generator.subset(\"one\", \"two\", \"three\")\n        .simple()\n        .stream()\n        .forEach(System.out::println);\n```\nAnd the list of all 8 subsets\n```\n   []\n   [one]\n   [two]\n   [one, two]\n   [three]\n   [one, three]\n   [two, three]\n   [one, two, three]\n```\n\n### 7. Integer Partitions\nIn number theory, a partition of a positive integer `n` is a way of writing `n` as a sum of positive integers. \nTwo sums that differ only in the order of their summands are considered to be the same partition; \nif order matters then the sum becomes a composition. A summand in a partition is also called a part.\n\nThe partitions of 5 are listed below:\n\n- 1 + 1 + 1 + 1 + 1\n- 2 + 1 + 1 + 1\n- 2 + 2 + 1\n- 3 + 1 + 1\n- 3 + 2\n- 4 + 1\n- 5\n\nLet's generate all possible partitions of 5:\n```java\n   Generator.partition(5)\n       .stream()\n       .forEach(System.out::println);\n```\nAnd the result of all 7 integer possible partitions:\n```\n   [1, 1, 1, 1, 1]\n   [2, 1, 1, 1]\n   [2, 2, 1]\n   [3, 1, 1]\n   [3, 2]\n   [4, 1]\n   [5]\n```\n\n\n### 8. Cartesian Product\nIn set theory, a Cartesian Product A × B is the set of all ordered pairs (a, b) where a ∈ A and b ∈ B.\n\nAs an example, suppose there are 2 sets of number, (1, 2, 3) and (4, 5, 6), and you want to get the Cartesian product of the two sets.\n\nSource: [Cartesian Product](https://en.wikipedia.org/wiki/Cartesian_product)\n\n```java\n       Generator.cartesianProduct(Arrays.asList(1, 2, 3), Arrays.asList(4, 5, 6))\n           .stream()\n           .forEach(System.out::println);\n```\nAnd the result will be:\n\n```\n   [1, 4]\n   [1, 5]\n   [1, 6]\n   [2, 4]\n   [2, 5]\n   [2, 6]\n   [3, 4]\n   [3, 5]\n   [3, 6]\n```\n","funding_links":[],"categories":["Java"],"sub_categories":["Parsers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpaukov%2Fcombinatoricslib3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpaukov%2Fcombinatoricslib3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpaukov%2Fcombinatoricslib3/lists"}