-
Notifications
You must be signed in to change notification settings - Fork 0
/
stringChallenge.php
42 lines (37 loc) · 1.07 KB
/
stringChallenge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
$string = "фывф5 ывфы???фывфы5???вфыв???";
function StringChallenge($string)
{
$strings = explode('???',$string);
$a = (int)filter_var($strings[0], FILTER_SANITIZE_NUMBER_INT);
$b = (int)filter_var($strings[1], FILTER_SANITIZE_NUMBER_INT);
if ($a + $b == 10)
{
return true;
} else {
return false;
}
}
StringChallenge($string);
function assertBool($string, $target) {
if (stringChallenge($string) !== $target) {
echo "Error on $string-> Should be " . (($target)?"true":"false") . PHP_EOL;
} else {
echo "Passed: $string" . PHP_EOL;
}
}
assertBool('10', false);
assertBool('2??9', false);
assertBool('2???9', false);
assertBool('1???9', true);
assertBool('???9', false);
assertBool('2???', false);
assertBool('ff2???', false);
assertBool('fdsf1???9', true);
assertBool('1???9125tgdc', false);
assertBool('asd5???5asdasdf', true);
assertBool('???5jngnc', false);
assertBool('112???9', false);
assertBool('112???9???11', false);
assertBool('112???9???1', true);
assertBool('123ffff5???5fff', true);