You are viewing a single comment's thread. Return to all comments →
IMHO, I would preffer saying "it depends", if I had to reuse this code for some reason,it would be written as a function or a method, in this case the array would be provided as a parameter, therefore storing it is not an option, it is mandatory.
Another scenario would be calculating the difference as part of the processing, as you've mentioned.
But I defenitely agree that to solve this specific problem you don't need to store the information.
Well, you don't need to use the array, only the diagonals, as the task is very specific. Building on the idea that we might need to use the array later feels like a cop-out to explain bad coding. If you'd need to use the array values, you would be given a different task, not this one.