$max_value) { $max_value = $next_houses_values; } $house_index++; } $cache[implode(",",$houses)] = $houses[0] + $max_value; return $houses[0] + $max_value; } if (get_houses_max([2,4,5]) != 7) { throw new Exception('Failed test 1'); } $cache = []; if (get_houses_max([4, 2, 3, 6, 5, 3]) != 13) { throw new Exception('Failed test 2'); } ?>