-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0502.php
More file actions
34 lines (31 loc) · 715 Bytes
/
0502.php
File metadata and controls
34 lines (31 loc) · 715 Bytes
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
<?php
$n = 4;
echo (-1) * $n;
function invert(array $a): array
{
var_dump($a);
$b = array();
foreach ($a as $key => $value) {
array_push($b, ($value * -1));
}
return $b;
}
var_dump(invert([1, 2, -3, -4, 5, -6]));
echo "<br>--------------<br>";
function points(array $games): int
{
$points = 0;
foreach ($games as $key => $value) {
// echo $value;
$ar = str_split($value, 1);
if ($ar[0] > $ar[2]) {
$points += 3;
} elseif ($ar[0] < $ar[2]) {
$points += 0;
} else {
$points += 1;
}
}
return $points;
}
echo points(['1:0', '2:0', '3:0', '4:4', '2:2', '3:3', '1:4', '2:3', '2:4', '3:4']);