Problem statement
Given a square grid, add every cell on both diagonals, counting a cell once even when the two diagonals share it.
The answer is one number, and the grid is never changed.
Examples
Inputm = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Output25
1 + 5 + 9 + 3 + 5 + 7 counts the centre 5 twice, so one 5 is taken back out.
Inputm = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
Output68
On an even side the two diagonals share no cell, so nothing is subtracted.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing