Skip to content

Instantly share code, notes, and snippets.

@reazul-islam
Last active January 5, 2022 08:01
Show Gist options
  • Select an option

  • Save reazul-islam/8134069c672a742a396103018eb2e5ea to your computer and use it in GitHub Desktop.

Select an option

Save reazul-islam/8134069c672a742a396103018eb2e5ea to your computer and use it in GitHub Desktop.

Revisions

  1. reazul-islam revised this gist Oct 25, 2021. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion gistfile1.txt
    Original 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]);
    }
    }


    ?>
  2. reazul-islam created this gist Oct 25, 2021.
    78 changes: 78 additions & 0 deletions gistfile1.txt
    Original 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]);
    }