News for hackers. Stuff that matters.
Re:Applying the Linus Torvalds “Good Taste” Coding Requirement by tomerv on Wednesday October 26, 2016 @07:08AM (#12795514)
Here's my fix:

  for (i = 0; i < GRID_SIZE - 1; ++i) { // Note the "-1"...
  
      // Top Edge
      grid[0][i] = 0;
  
      // Bottom Edge
      grid[GRID_SIZE - 1][GRID_SIZE - i - 1] = 0; // Reverse the order: from left to right
  
      // Left Edge
      grid[GRID_SIZE - i - 1][0] = 0; // Reverse the order: from bottom to top
  
      // Right Edge
      grid[i][GRID_SIZE - 1] = 0;
  }
This way, for every row/column, the loop acts on all but the last cell, which is actually the first cell of some other column/row.
Re:Applying the Linus Torvalds “Good Taste” Coding Requirement by danielsamuels on Wednesday October 26, 2016 @09:17AM (#12796178)
I feel like for the each side you could actually handle two items per iteration, one forwards _and_ one backwards. That way your iteration count could be halved.
Re:Applying the Linus Torvalds “Good Taste” Coding Requirement by tbabb on Wednesday October 26, 2016 @01:49PM (#12798719)
That doesn't reduce the number of cells touched, and would make the algorithm more complicated. It would also probably hurt cache locality. Going backwards is also pointless complication, you could just as easily cut into two sections and go forward in both.

And furthermore why split in two? Why not split the range into three sections, or four, or N and completely unroll the loop?

Probably not a good-tasting construct at all.

Re:Applying the Linus Torvalds “Good Taste” Coding Requirement by wang_li on Wednesday October 26, 2016 @11:14AM (#12797086)
And what do you do with odd grid sizes?

Honestly the whole second half seemed damned weird. Give the requirement to zero the edges of a two dimensional array, it's so astonishingly obvious to just hard code the 0 and width-1/height-1 that do do anything else suggests a special effort to make a sub-optimal solution simply for arguments sake.