board of integers. Call a 3×3 block *magic* if it holds every digit from 1 to 9 exactly once and its three rows, three columns and both diagonals all have the same sum.
Count how many magic 3×3 blocks (made of adjacent rows and columns) appear on the board. Blocks may overlap.
The board may also contain zeros and numbers above 9; a block containing one of them is never magic.board=[[2, 7, 6, 2], [9, 5, 1, 9], [4, 3, 8, 4]] → 1
The left 3×3 block holds each digit 1–9 once, and every row, column and both diagonals add up to 15. The right block (columns 1–3) repeats the 9, so it does not count.
board=[[5, 5, 5], [5, 5, 5], [5, 5, 5]] → 0
Every sum is 15, but the digits repeat, so the block is not magic.
board=[[12, 3], [0, 7]] → 0
The board is smaller than 3×3, so there are no blocks at all.
board[i][j] ≤ 15board=[[2, 7, 6, 2], [9, 5, 1, 9], [4, 3, 8, 4]]
1
Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.