@@ -0,0 +1,707 @@
+def spiral_diag_numbers(n):%0A    yield 1%0A    lvl = 1%0A    while True:%0A        width = lvl * 2 + 1%0A        last = width ** 2%0A        step = 2*lvl%0A        if width %3E n:%0A            break%0A        yield from range(last, last-3*step-1, -step)%0A        lvl += 1%0A%0Aif __name__ == '__main__':%0A    # first attempt%0A    # ans = sum(spiral_diag_numbers(5))%0A%0A    # second attemp%0A    # for layer k, the side length is: n = 2*k + 1%0A    # corners of each layer%0A    # top right: n**2%0A    # top left: n**2 - n + 1%0A    # bottom left: n**2 - 2n + 2%0A    # bottom right: n**2 - 3n + 3%0A    # sum of four corners: 4*n**2 - 6n + 6%0A    ans = 1 + sum(4 * n ** 2 - 6 * n + 6%0A                  for n%0A                  in range(3, 1003, 2))%0A

complete 29 number spiral diagonals