forked from exercism/php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
38 lines (29 loc) · 785 Bytes
/
example.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
<?php
declare(strict_types=1);
class Sublist
{
public function compare(array $listOne, array $listTwo): string
{
if (count($listOne) === 0 && count($listTwo) === 0) {
return "EQUAL";
}
if (count($listOne) > 0 && count($listTwo) === 0) {
return "SUPERLIST";
}
if (count($listOne) === 0 && count($listTwo) > 0) {
return "SUBLIST";
}
$one = implode(',', $listOne) . ',';
$two = implode(',', $listTwo) . ',';
if ($one === $two) {
return "EQUAL";
}
if (str_contains($one, $two)) {
return "SUPERLIST";
}
if (str_contains($two, $one)) {
return "SUBLIST";
}
return "UNEQUAL";
}
}