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
Влез, за да видиш историята на решенията
ВходВлез, за да използваш ИИ ментора
ВходVisible tests
1
Input
1Expected
12
Input
3Expected
253
Input
5Expected
1014
Input
7Expected
2615
Input
1001Expected
6691710016
Input
999999Expected
666665166669000000Focus radio
Paused · SomaFM · Fluid