Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
So, been struggling with this for an hour now, and i can't quite understand what i'm doing wrong. i even quit the kata to see the answers, but i still want to know what was wrong with my solution. any reply will be highly appreciated.
my code below (nowhere near good practice probably but i'm new to php so i'm trying to understand the concept before using methods like array_map()
function comp($a1, $a2) {
$answer = true;
$arr = array();
foreach($a1 as $val) {
$sqr = $val*$val;
array_push($arr, $sqr);
}
sort($arr);
sort($a2);
if (is_null($a1) || is_null($a2) || $arr != $a2 || count($arr) != count($a2) || !is_array($a1) || !is_array($a2) || count($a1) == 0 || count($a2) == 0){
return false;
} else {
return true;
}
}