[Community Puzzle] Sum of Spiral's diagonals

Hi to all :slight_smile: ! I agree with @5DN1L : that’s not an error :
→ your task is not to add twice a value in the square, nor in the diagonals :wink:

Hope u found useful our help tip ?
+Please, don’t forget : have :sun_with_face: sun, :dark_sunglasses: fun and codingames :wink: !

Typos, it’s 8n - 15, 12n - 35 and 13n - 42 (the rest of the computation is good so I guess you had it right on your side but wrong when writing your comment)

1 Like

Your solution has complexity O(n) not O(1).

…my final solution has been “censored” for not spoiler to others, so you didn’t see it…

it is O(1) since it uses a fixed number of operations, regardless of n value

I found the solution, it is cool when you can generalize problem and find an equation.