PHP Classes

How Can PHP Calculate Combinations and Permutations of Numbers Using the Class Math Combinatorics: Combinations and permutations of a set of values

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-06-28 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 31 All time: 11,098 This week: 59Up
Version License PHP version Categories
math_combinatorics 1.0.0MIT/X Consortium ...7Math, PHP 7
Description 

Author

This class can get the combinations and permutations of a set of values.

It can take an array of numbers and calculate the combinations and the permutations between the numbers in the array.

The class returns an array with the resulting combinations and permutations.

Picture of Chun-Sheng, Li
  Performance   Level  
Name: Chun-Sheng, Li <contact>
Classes: 37 packages by
Country: Taiwan Taiwan
Age: 31
All time rank: 21046 in Taiwan Taiwan
Week rank: 4 Up1 in Taiwan Taiwan Up
Innovation award
Innovation award
Nominee: 17x

Winner: 1x

Example

<?php

   
require_once 'Combinatorics.php';

   
$combinatorics = new Math_Combinatorics;
   
$set = range(0, 9);
   
   
$asc_num = 97;
    while (
$asc_num<= 122) {
       
# code...
       
array_push($set, chr($asc_num));
       
$asc_num++;
    }

   
//??
   
echo $combinations = $combinatorics->combinations($set, 16);
   
//??
    //$permutations = $combinatorics->permutations($set, 16);
?>


Details

Math_Combinatorics

This project is appropriate for someone who want to know about the combinations and permumentations.

different

If you use Math_Combinatorics, it will happen an error that show memories' limit.In order to solving problem,I tried to changing source code.I use file_put_content function that stroe strings when generating a new possible string right away. I also free the variable's memory which assigned the possible string so that it will not happen memories' error.

Requirement

It's only have to use PHP command line.

Dependency

It depends on this package: Math_Combinatorics


  Files folder image Files (3)  
File Role Description
Plain text file Combinatorics.php Class Class source
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:31
This week:0
All time:11,098
This week:59Up