# Tag Info

4

Some suggestions on coding style: Your choice in variables is somewhat confusing i, j? For an algorithm operating on a 2D image, the names x and y would be better. And dx, dy for the offsets in the inner loop. You defined the width of your kernel as SQUARE, yet you hardcode 2 in the expression image[i][j+2]. Your boundary checks can be more efficient. Why ...

1

The code in general is pretty good, so I don't have a lot to suggest, just a handful of pointers. As already mentioned, variable naming could be a little better. For example, I'm not sure why your two most inner loops use the variables "k" and "y". "SQUARE" would probably be better named as "SQUARE_SIZE". outerArr and ...

1

Computation of rsi1 (and rsi2) are a bit more complicated as necessary. Gains and losses are accumulated in their respective lists, only to be summed later on. Get rid of the lists: if today > yesterday: gain += today - yesterday else: loss += yesterday - today Computing averages is also redundant. averagegain1 = ...

1

Algorithm One optimization in terms of space complexity would be to store the names in a separate array and use a simpler data type for the permutations (e.g. integer - could be indexes of the array). I also see this block within the compute method: $i=0;$total = 0; $n = count($this->locations)-1; foreach ($perms as$...

Only top voted, non community-wiki answers of a minimum length are eligible