You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have the some code that looks a bit like this (condensed slightly to fit in this tiny edit box):
intflipped = 0;
for (intresult : results)
if (result > 0) flipped += result;
if (flipped < 0) returnfalse;
It seems to me that there is no way the "return false" can be reached here, because the sum of positive numbers is never negative (assuming no integer overflow).
Granted, these kind of details aren't really the point of Chapter 7, which is more "big picture stuff" it's still nice if demo code actually works. (The code that centers the initial 4 pieces on the board is also wrong, but that's relatively cosmetic.)
The text was updated successfully, but these errors were encountered:
On this line in the Othello code:
https://github.com/careercup/CtCI-6th-Edition/blob/master/Java/Ch%2007.%20Object-Oriented%20Design/Q7_08_Othello/Board.java#L40
We have the some code that looks a bit like this (condensed slightly to fit in this tiny edit box):
It seems to me that there is no way the "return false" can be reached here, because the sum of positive numbers is never negative (assuming no integer overflow).
Granted, these kind of details aren't really the point of Chapter 7, which is more "big picture stuff" it's still nice if demo code actually works. (The code that centers the initial 4 pieces on the board is also wrong, but that's relatively cosmetic.)
The text was updated successfully, but these errors were encountered: