by LambdaComplex · 1y ago · 0 comments
And if I did have to do something like that at work, I promise my manager would give me more than 25 minutes to do it.
sum += (x > 0 && y > 0 && x < x_limit && y < y_limit) ? a[y][x] : 0;
That took less than a minute of thought; or you could use a common technique in image and video processing, which is to make sure that the edges are always present but filled with appropriate values by defining your grid to be slightly bigger than the active area. >=-- joking -- :)