Spiral Diagonal Sum

Imagine an odd-sized square grid size x size where numbers are written from the center in a clockwise spiral. Write a function spiral_diagonal_sum that finds the sum of the numbers that land on the two diagonals. For a small grid, you can check the pattern by eye, but for a larger one it helps to notice how the spiral grows layer by layer.

Примеры

Ввод
1
Вывод
1
Ввод
3
Вывод
25
Ввод
5
Вывод
101

Нужно реализовать

def spiral_diagonal_sum(size: int) -> int:

Теги

math
PostgreSQLv16

Čia bus kodo vykdymo rezultatas

Visible tests
1
Input
1
Expected1
2
Input
3
Expected25
3
Input
5
Expected101
4
Input
7
Expected261
5
Input
1001
Expected669171001
6
Input
999999
Expected666665166669000000
Focus radio
Paused · SomaFM · Fluid