← Back to challenges

Compare Diagonal

PythonHardarraysloops

Instructions

Create a function that returns the right diagonal of a matrix if the sum of the right diagonal is greater than or equal to the sum of the left diagonal, else returns the left diagonal.

Examples

compare_diagonals([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) ➞ [3, 5, 7]

Notes

The matrix will be a square matrix of any order.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.