Skip to content

Instantly share code, notes, and snippets.

@buvinghausen
Last active March 9, 2026 15:36
Show Gist options
  • Select an option

  • Save buvinghausen/dd9bdaa442665c78c299e759f1314aba to your computer and use it in GitHub Desktop.

Select an option

Save buvinghausen/dd9bdaa442665c78c299e759f1314aba to your computer and use it in GitHub Desktop.
static int[][] Minesweeper(bool[][] matrix) => [.. matrix
.Select((row, i) => row
.Select((_, j) => matrix
.Skip(i - 1)
.Take(i == 0 ? 2 : 3)
.SelectMany(r => r
.Skip(j - 1)
.Take(j == 0 ? 2 : 3))
.Count(m => m) - (matrix[i][j] ? 1 : 0))
.ToArray()
)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment