News for hackers. Stuff that matters.
Re:Self-Taught Engineers Often Outperform by LambdaComplex on Friday July 18, 2025 @12:41AM (#44601272)
I've solved plenty of hard problems at work, but none of them have ever looked like "count the grid squares adjacent to a given grid square while taking the grid's edges into account so the program doesn't blow up because you tried to access an invalid index."

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.

Re:Self-Taught Engineers Often Outperform by userbinator on Friday July 18, 2025 @01:10AM (#44601412)

    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.
Re:Self-Taught Engineers Often Outperform by what on Friday July 18, 2025 @01:57AM (#44601643)
And it doesn’t do what’s asked? Congrats.
Re:Self-Taught Engineers Often Outperform by userbinator on Friday July 18, 2025 @02:53AM (#44601953)
I just concentrated on what would be the hardest part, the "edge" cases (literally.) Wrapping that in a loop that goes through the appropriate indices is not much more work. There is a sibling dead comment to mine which has the rest.
Re:Self-Taught Engineers Often Outperform by peterfirefly on Friday July 18, 2025 @06:20AM (#44603060)
Should probably use

  >=
Re:Self-Taught Engineers Often Outperform by userbinator on Friday July 18, 2025 @09:42PM (#44611778)
You're assuming closed instead of open intervals.
Re:Self-Taught Engineers Often Outperform by peterfirefly on Sunday July 20, 2025 @09:00AM (#44624810)
I was assuming zero-based arrays.
Re:Self-Taught Engineers Often Outperform by jay_kyburz on Friday July 18, 2025 @02:04AM (#44601684)
oops doesn't count the edges. Take another minute.

-- joking -- :)