diff --git a/DIRECTORY.md b/DIRECTORY.md index 7458a59..b28c078 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -1,84 +1,94 @@ # List of all files ## Ciphers - * [Caesarcipher](./Ciphers/CaesarCipher.php) - * [Monoalphabeticcipher](./Ciphers/MonoAlphabeticCipher.php) - * [Morsecode](./Ciphers/MorseCode.php) - * [Xorcipher](./Ciphers/XORCipher.php) + +- [Caesarcipher](./Ciphers/CaesarCipher.php) +- [Monoalphabeticcipher](./Ciphers/MonoAlphabeticCipher.php) +- [Morsecode](./Ciphers/MorseCode.php) +- [Xorcipher](./Ciphers/XORCipher.php) ## Conversions - * [Binarytodecimal](./Conversions/BinaryToDecimal.php) - * [Decimaltobinary](./Conversions/DecimalToBinary.php) - * [Hexadecimaltodecimal](./Conversions/HexadecimalToDecimal.php) - * [Octaltodecimal](./Conversions/OctalToDecimal.php) + +- [Binarytodecimal](./Conversions/BinaryToDecimal.php) +- [Decimaltobinary](./Conversions/DecimalToBinary.php) +- [Hexadecimaltodecimal](./Conversions/HexadecimalToDecimal.php) +- [Octaltodecimal](./Conversions/OctalToDecimal.php) ## Maths - * [Absolutemax](./Maths/AbsoluteMax.php) - * [Absolutemin](./Maths/AbsoluteMin.php) - * [Checkprime](./Maths/CheckPrime.php) - * [Factorial](./Maths/Factorial.php) - * [Fastexponentiation](./Maths/FastExponentiation.php) - * [Fibonacci](./Maths/Fibonacci.php) - * [Fibonacci2](./Maths/Fibonacci2.php) - * [Perfectsquare](./Maths/PerfectSquare.php) - * Projecteuler - * [Problem1](./Maths/ProjectEuler/Problem1.php) - * [Problem2](./Maths/ProjectEuler/Problem2.php) - * [Problem3](./Maths/ProjectEuler/Problem3.php) - * [Problem5](./Maths/ProjectEuler/Problem5.php) - * [Problem6](./Maths/ProjectEuler/Problem6.php) - * [Problem7](./Maths/ProjectEuler/Problem7.php) - * [Problem9](./Maths/ProjectEuler/Problem9.php) + +- [Absolutemax](./Maths/AbsoluteMax.php) +- [Absolutemin](./Maths/AbsoluteMin.php) +- [Checkprime](./Maths/CheckPrime.php) +- [Factorial](./Maths/Factorial.php) +- [Fastexponentiation](./Maths/FastExponentiation.php) +- [Fibonacci](./Maths/Fibonacci.php) +- [Fibonacci2](./Maths/Fibonacci2.php) +- [Perfectsquare](./Maths/PerfectSquare.php) +- Projecteuler + - [Problem1](./Maths/ProjectEuler/Problem1.php) + - [Problem2](./Maths/ProjectEuler/Problem2.php) + - [Problem3](./Maths/ProjectEuler/Problem3.php) + - [Problem5](./Maths/ProjectEuler/Problem5.php) + - [Problem6](./Maths/ProjectEuler/Problem6.php) + - [Problem7](./Maths/ProjectEuler/Problem7.php) + - [Problem9](./Maths/ProjectEuler/Problem9.php) ## Searches - * [Binarysearch](./Searches/BinarySearch.php) - * [Fibonaccisearch](./Searches/FibonacciSearch.php) - * [Jumpsearch](./Searches/JumpSearch.php) - * [Linearsearch](./Searches/LinearSearch.php) - * [Lowerbound](./Searches/LowerBound.php) - * [Upperbound](./Searches/UpperBound.php) + +- [Binarysearch](./Searches/BinarySearch.php) +- [Fibonaccisearch](./Searches/FibonacciSearch.php) +- [Jumpsearch](./Searches/JumpSearch.php) +- [Linearsearch](./Searches/LinearSearch.php) +- [Lowerbound](./Searches/LowerBound.php) +- [Upperbound](./Searches/UpperBound.php) ## Sorting - * [Arraykeyssort](./Sorting/ArrayKeysSort.php) - * [Bubblesort](./Sorting/BubbleSort.php) - * [Bubblesort2](./Sorting/BubbleSort2.php) - * [Countsort](./Sorting/CountSort.php) - * [Insertionsort](./Sorting/InsertionSort.php) - * [Mergesort](./Sorting/MergeSort.php) - * [Quicksort](./Sorting/QuickSort.php) - * [Radixsort](./Sorting/RadixSort.php) - * [Selectionsort](./Sorting/SelectionSort.php) + +- [Arraykeyssort](./Sorting/ArrayKeysSort.php) +- [Bubblesort](./Sorting/BubbleSort.php) +- [Bubblesort2](./Sorting/BubbleSort2.php) +- [Countsort](./Sorting/CountSort.php) +- [Gnomesort](./Sorting/GnomeSort.php) +- [Insertionsort](./Sorting/InsertionSort.php) +- [Mergesort](./Sorting/MergeSort.php) +- [Quicksort](./Sorting/QuickSort.php) +- [Radixsort](./Sorting/RadixSort.php) +- [Selectionsort](./Sorting/SelectionSort.php) ## Strings - * [Checkanagram](./Strings/CheckAnagram.php) - * [Checkpalindrome](./Strings/CheckPalindrome.php) - * [Checkpalindrome2](./Strings/CheckPalindrome2.php) - * [Countconsonants](./Strings/CountConsonants.php) - * [Countsentences](./Strings/CountSentences.php) - * [Countvowels](./Strings/CountVowels.php) - * [Distance](./Strings/Distance.php) - * [Maxcharacter](./Strings/MaxCharacter.php) - * [Reversestring](./Strings/ReverseString.php) - * [Reversewords](./Strings/ReverseWords.php) + +- [Checkanagram](./Strings/CheckAnagram.php) +- [Checkpalindrome](./Strings/CheckPalindrome.php) +- [Checkpalindrome2](./Strings/CheckPalindrome2.php) +- [Countconsonants](./Strings/CountConsonants.php) +- [Countsentences](./Strings/CountSentences.php) +- [Countvowels](./Strings/CountVowels.php) +- [Distance](./Strings/Distance.php) +- [Maxcharacter](./Strings/MaxCharacter.php) +- [Reversestring](./Strings/ReverseString.php) +- [Reversewords](./Strings/ReverseWords.php) ## Tests - * Ciphers - * [Cipherstest](./tests/Ciphers/CiphersTest.php) - * [Monoalphabeticciphertest](./tests/Ciphers/MonoAlphabeticCipherTest.php) - * [Morsecodetest](./tests/Ciphers/MorseCodeTest.php) - * Conversions - * [Conversionstest](./tests/Conversions/ConversionsTest.php) - * Maths - * [Mathstest](./tests/Maths/MathsTest.php) - * [Projecteulertest](./tests/Maths/ProjectEulerTest.php) - * Searches - * [Searchestest](./tests/Searches/SearchesTest.php) - * Sorting - * [Arraykeyssorttest](./tests/Sorting/ArrayKeysSortTest.php) - * [Sortingtests](./tests/Sorting/SortingTests.php) - * Strings - * [Stringstest](./tests/Strings/StringsTest.php) + +- Ciphers + - [Cipherstest](./tests/Ciphers/CiphersTest.php) + - [Monoalphabeticciphertest](./tests/Ciphers/MonoAlphabeticCipherTest.php) + - [Morsecodetest](./tests/Ciphers/MorseCodeTest.php) +- Conversions + - [Conversionstest](./tests/Conversions/ConversionsTest.php) +- Maths + - [Mathstest](./tests/Maths/MathsTest.php) + - [Projecteulertest](./tests/Maths/ProjectEulerTest.php) +- Searches + - [Searchestest](./tests/Searches/SearchesTest.php) +- Sorting + - [Arraykeyssorttest](./tests/Sorting/ArrayKeysSortTest.php) + - [Gnomesorttest](./tests/Sorting/GnomeSortTest.php) + - [Sortingtests](./tests/Sorting/SortingTests.php) +- Strings + - [Stringstest](./tests/Strings/StringsTest.php) ## Utils - * [Arrayhelpers](./Utils/ArrayHelpers.php) - * [Executiontime](./Utils/ExecutionTime.php) + +- [Arrayhelpers](./Utils/ArrayHelpers.php) +- [Executiontime](./Utils/ExecutionTime.php) diff --git a/Sorting/GnomeSort.php b/Sorting/GnomeSort.php new file mode 100644 index 0000000..003e097 --- /dev/null +++ b/Sorting/GnomeSort.php @@ -0,0 +1,34 @@ +assertEquals([-1, 0, 1, 2, 3, 4, 5], $sorted); + } + + public function testGnomeSort2() + { + $array = array(8, -50, 1, 90, 35, 47, 69, -5); + $sorted = gnomeSort($array); + $this->assertEquals([-50, -5, 1, 8, 35, 47, 69, 90], $sorted); + } +}