How Far Have You Gotten in Leet
1 min readDec 30, 2020
*** This solution came from Keshav613’s explanation.
Question
Explanation
- The first player always starts with ‘X’, which means that the number of X must be greater than or equal to the number of O when the game ends.
- The game ends when three of the same character fill any row, column, or diagonal. Basically, no more than one sequence must be created when the game ends.
- There are two special cases when two sequences could be made in a game. First, when ‘X’ makes two, X must be one more than O. Secondly, when ‘O’ makes two, O must be equal to X.
- Every other game could reach the designated board position.
Solution
Review
Didn’t make it to handle the special cases and, as a result, failed over and over again. The original code was kinda brute-force solution, which gets rid of all the impossible cases found, rather than a logical solution. When It could not be possible to find out all the exceptions, try to make a logic first.