Last active
January 5, 2022 08:01
-
-
Save reazul-islam/8134069c672a742a396103018eb2e5ea to your computer and use it in GitHub Desktop.
Revisions
-
reazul-islam revised this gist
Oct 25, 2021 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ <?php function backwardsPrime($start, $stop) { $result = []; @@ -75,4 +77,7 @@ function backwardsPrime($start, $stop) // enter your magic here preg_match_all('/[aeiou]/i', $str, $matches); return count($matches[0]); } ?> -
reazul-islam created this gist
Oct 25, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ function backwardsPrime($start, $stop) { $result = []; for ($val = $start; $val <= $stop; $val++) { if ((isPrimeCheck($val) && isPrimeCheck(strrev($val)) && $val != strrev($val))) { $result[] = $val; } } return $result; } function isPrimeCheck($num) { for ($i=2; pow($i, 2) <= $num; $i++) { if ($num %$i == 0) { return false; } } return true; } function nbDig($n, $d) { $count = 0; for ($i = 0; $i<= $n; $i++) { $sqr = $i*$i; $count += substr_count($sqr, (string)$d); // $position = substr_count($sqr, (string)$d); // if (!is_bool($position)) { // echo $sqr.'<br>'; // } //echo $i*$i .'<br>'; } echo $count; } function solution($n) { $arr = [4=>7, 7=>4]; return array_search($n, $arr); } function parse($data) { $data = strtolower($data); $value = 0; $result = []; for ($i=0; $i< strlen($data); $i++) { $input = $data[$i]; if ($input == 'i') { ++$value; } elseif ($input == 'd') { --$value; } elseif ($input == 's') { $value *=$value; } elseif ($input == 'o') { $result[] = $value; } } return $result; } function getAge($response) { // return correct age (int). Happy coding :) $age = substr($response, 0, 1); $age = (int)$age; return $age; } function isPangram($string) { $string = preg_replace('/[^a-z]+/', '', strtolower($string)); $string = count_chars($string, 3); return (strlen($string) == 26); } function getCount($str) { $vowelsCount = 0; // enter your magic here preg_match_all('/[aeiou]/i', $str, $matches); return count($matches[0]); }