Created
June 27, 2018 15:01
-
-
Save roy-bukapeta/d07173e000b45eb428b27bd70f14b71f to your computer and use it in GitHub Desktop.
Challenge #1
This file contains 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 characters
<?php | |
function QuestionsMarks($str) | |
{ | |
$arrString = preg_split('/[0-9]/', $str, -1, PREG_SPLIT_NO_EMPTY); | |
preg_match_all('/[0-9]/', $str, $arrNumber); | |
$arrNumber = $arrNumber[0]; | |
for ($i=0; $i < count($arrNumber); $i++) { | |
if ($i < (count($arrNumber) - 1)) { | |
if (intval($arrNumber[$i]) + intval($arrNumber[($i + 1)]) <= 10 && substr_count($arrString[($i + 1)], '?') == 3) { | |
return 'true'; | |
} | |
} | |
} | |
return 'false'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment