Skip to content

Instantly share code, notes, and snippets.

@RTLer
Created May 14, 2016 07:03
Show Gist options
  • Save RTLer/522410ef174c5bf7c75d72a7c5b86dbb to your computer and use it in GitHub Desktop.
Save RTLer/522410ef174c5bf7c75d72a7c5b86dbb to your computer and use it in GitHub Desktop.
/**
* codekata
*
* @param null $number1
* @param null $number2
* @param null $number3
* @param array $notIn
* @return array
*/
function generator($number1 = null, $number2 = null, $number3 = null, $notIn = [])
{
$arr = [];
for ($i = 102; $i < 987; $i++) {
$str = (string)$i;
if ((in_array($str[0], $notIn) || in_array($str[1], $notIn) || in_array($str[2], $notIn))
|| $str[0] == $str[1] || $str[0] == $str[2] || $str[1] == $str[2]
) {
continue;
}
if ((is_null($number1) || $str[0] == $number1) &&
(is_null($number2) || $str[1] == $number2) &&
(is_null($number3) || $str[2] == $number3)
) {
$arr[] = $i;
}
}
return $arr;
}
$arr = generator(null, null, 6, [0,1,2,3, 4, 5,7]);
print_r($arr);
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment