diff --git a/Challenge 1 - Sorting/challenge1.php b/Challenge 1 - Sorting/challenge1.php index a4abe2d..a75a22b 100644 --- a/Challenge 1 - Sorting/challenge1.php +++ b/Challenge 1 - Sorting/challenge1.php @@ -1,2 +1,45 @@ max = $max; + $this->min = $min; + } + + public function sortNumbers(){ + //Even though it's set to 100 numbers, count in case it changes later. + $count = count($this->numbers); + + for($i = 0; $i < $count; $i++){ + for($j = 0;$j < $count-1; $j++){ + if($this->numbers[$j] > $this->numbers[$j+1]){ + $k = $this->numbers[$j+1]; + $this->numbers[$j+1] = $this->numbers[$j]; + $this->numbers[$j] = $k; + } + } + } + + return $this->numbers; + } + + public function genNum(){ + for($i = 0; $i < 100; $i++){ + //this highlights why we don't use rand or mt_rand for true randomness. + $this->numbers[] = rand($this->min,$this->max); + } + + return $this->numbers; + } +} +$class = new MakeSort(1,99); +print_r('Unsorted List:'); +print_r($class->genNum()); +print_r('Sorted Numbers:'); +print_r($class->sortNumbers()); + +?> \ No newline at end of file diff --git a/Challenge 2 - Uppercase/challenge2.php b/Challenge 2 - Uppercase/challenge2.php index a4abe2d..44307bc 100644 --- a/Challenge 2 - Uppercase/challenge2.php +++ b/Challenge 2 - Uppercase/challenge2.php @@ -1,2 +1,17 @@ \ No newline at end of file diff --git a/Challenge 3 - Cryptography/challenge3.php b/Challenge 3 - Cryptography/challenge3.php index a4abe2d..db28d56 100644 --- a/Challenge 3 - Cryptography/challenge3.php +++ b/Challenge 3 - Cryptography/challenge3.php @@ -1,2 +1,5 @@ \ No newline at end of file diff --git a/Challenge 4 - 3n+1/challenge4.php b/Challenge 4 - 3n+1/challenge4.php index e69de29..b817751 100644 --- a/Challenge 4 - 3n+1/challenge4.php +++ b/Challenge 4 - 3n+1/challenge4.php @@ -0,0 +1,20 @@ +"); + break; + default: + $n = ($n*3)+1; + print_r($n . "
"); + break; + } + } while($n != 1); +} + +algorithm(57); + +?> \ No newline at end of file