Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a tangent, but checking if all the elements in the diagonal position are the same is not sufficient. You also need to check that any of the elements are not '-'.


Depends how the flow goes. It's reasonable to only check the diagonal when one player has actually played on the diagonal, in which case this is fine.


That’s… what the article says.


That’s not what the article says. The last paragraph:

  if (cell[0][0] == cell[1][1] == cell[2][2]) {
      return Winner
  }
> Well the code is indeed correct . Well done, Python… for finding yet another way to confuse us all.

The code is incorrect: if all entries are '-' there is no winner. Even ignoring the braces…


You do not know how the game was implemented to assume that.


To be fair to parent I read the whole thing and also missed that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: