Skip to content

Instantly share code, notes, and snippets.

@buvinghausen
Last active May 27, 2021 01:24
Show Gist options
  • Save buvinghausen/dd9bdaa442665c78c299e759f1314aba to your computer and use it in GitHub Desktop.
Save buvinghausen/dd9bdaa442665c78c299e759f1314aba to your computer and use it in GitHub Desktop.
using System.Linq;
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()).ToArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment