Skip to content

Instantly share code, notes, and snippets.

@mdibaiee
Created September 22, 2015 13:13
Show Gist options
  • Save mdibaiee/9395527d06aa12b6c1d1 to your computer and use it in GitHub Desktop.
Save mdibaiee/9395527d06aa12b6c1d1 to your computer and use it in GitHub Desktop.
tic tac toe
function isSolved(board) {
board = board.join('-').replace(/,/g,'');
if(/222|2...2...2|2....2....2|2..2..2/.test(board)) return 2;
if(/111|1...1...1|1....1....1|1..1..1/.test(board)) return 1;
if(/0/.test(board)) return -1;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment