Skip to content

Instantly share code, notes, and snippets.

@roy-bukapeta
Created June 27, 2018 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roy-bukapeta/d07173e000b45eb428b27bd70f14b71f to your computer and use it in GitHub Desktop.
Save roy-bukapeta/d07173e000b45eb428b27bd70f14b71f to your computer and use it in GitHub Desktop.
Challenge #1
<?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