Download the PHP package lishack/combinatorics-php without Composer

On this page you can find all versions of the php package lishack/combinatorics-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package combinatorics-php

PHP Combinatorics

A modern, type-safe combinatorics library for PHP 8.4+.

PHP Combinatorics provides efficient algorithms for counting, generating, ranking, and unranking combinatorial objects. It is designed for correctness, performance, and arbitrary-precision arithmetic using Brick\Math.

Unlike many combinatorics libraries, this project includes lazy generators, combination ranking and unranking algorithms, and exact calculations for extremely large numbers.

Features


Requirements


Installation

Install the package via Composer:


Why PHP Combinatorics?

Many existing PHP combinatorics libraries focus solely on counting functions or rely on native integers, which overflow for larger values.

PHP Combinatorics is designed to provide a complete toolkit for combinatorial mathematics with a modern, type-safe API.

Highlights


Documentation

The Combinatorics class provides a simple, static API for all supported combinatorial operations.

The library is divided into three main categories:

All counting methods return a Brick\Math\BigInteger, allowing exact calculations without integer overflow.

Counting

Counting methods calculate the number of possible results without generating them.

Method Description
factorial() Calculates the factorial of a non-negative integer.
binomial() Calculates the binomial coefficient C(n, k).
permutationsCount() Calculates the number of permutations.
variationsCount() Calculates the number of variations without repetition.
variationsWithRepetitionCount() Calculates the number of variations with repetition.
combinationsCount() Calculates the number of combinations without repetition.
combinationsWithRepetitionCount() Calculates the number of combinations with repetition.

Generators

Generator methods produce combinatorial objects lazily.

Instead of allocating every result in memory, values are generated only when requested during iteration.

Method Description
combinations() Generates combinations without repetition.
combinationsWithRepetition() Generates combinations with repetition.
permutations() Generates all permutations.
variations() Generates variations without repetition.
variationsWithRepetition() Generates variations with repetition.
powerSet() Generates the power set.
cartesianProduct() Generates the Cartesian product of multiple sets.

Ranking

Ranking methods assign unique numeric identifiers to combinations.

These methods are useful when combinations need to be stored, indexed, transferred, or reconstructed efficiently.

Method Description
combinationRank() Calculates the rank of a combination.
combinationUnrank() Restores a combination from its rank.

Examples

Counting

Factorial

Output


Binomial Coefficient

Output


Permutations Count

Output


Variations Count

Output


Variations Count With Repetition

Output


Combinations Count

Output


Combinations Count With Repetition

Output

Generators

Combinations

Output


Combinations With Repetition

Output


Permutations

Output


Variations

Output


Variations With Repetition

Output


Power Set

Output


Cartesian Product

Output

Ranking

Combination Rank (Lexicographic)

Output

The combinations are ordered as follows:

Rank Combination
0 [A, B]
1 [A, C]
2 [A, D]
3 [B, C]
4 [B, D]
5 [C, D]

Combination Rank (Colexicographic)

Output

The combinations are ordered as follows:

Rank Combination
0 [A, B]
1 [A, C]
2 [B, C]
3 [A, D]
4 [B, D]
5 [C, D]

Combination Unrank

Output


Ranking Custom Objects

Objects can be ranked by providing a key selector.

Output


Why Lazy Generation?

All generators return results one at a time.

Instead of allocating every possible result in memory, values are produced only when requested by the iterator.

This makes the library suitable for working with very large combinatorial spaces where generating every result at once would be impractical.


All versions of combinatorics-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
brick/math Version ^0.18.0
webmozart/assert Version ^2.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lishack/combinatorics-php contains the following files

Loading the files please wait ...