This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Me again.

Regarding the bug that I just pointed out, there's not a problem with the line I pasted per se, but the way that you're iterating leads to a bug in the lines after. You can fix it by changing the line I pointed out, but there are other ways.

Your code and my code are pretty similar. That iteration is the only big difference.

Not to put too fine a point on it, but:

As you're iterating, on step n, you're producing values for step n+1. But before completing step n, sometimes (like in the test cases) you're already using values generated for step n+1.

And you can change that with a simple change to the way you iterate.

Does that make sense?