Problem 58. Tic Tac Toe FTW
Given a tic tac toe board:
- 1 represents X
- 0 represents empty.
- -1 represents O
It is X's move. If there is an immediate win possibility, choose a square for an immediate win. Otherwise return 0.
Return absolute index of the square of choice. If multiple square are valid, return them in order.
Example:
Input a = [ 1 0 1 -1 1 0 0 -1 -1] Output wins is [3 4]
Solution Stats
Problem Comments
-
16 Comments
Show
13 older comments
Santosh Kasula
on 14 Jun 2019
@yurenchu - I fixed the test case 1 to start in a new line.
nag
on 16 Jun 2019
Thank you for fixing the test case!
Matthew
on 15 Jul 2025 at 20:12
Hilarious to see all the copy pasted solutions of size 700 when there are much simpler solutions. Gotta wonder why some people even bother.
Solution Comments
Show commentsProblem Recent Solvers1809
Suggested Problems
-
1280 Solvers
-
879 Solvers
-
16361 Solvers
-
619 Solvers
-
4709 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!