Skip to content

Instantly share code, notes, and snippets.

@masak
Created September 8, 2010 08:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save masak/569803 to your computer and use it in GitHub Desktop.
my @grid =
-1, 1, 1,
0, 1, 0,
-1, 1, -1,
;
my @lines =
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6],
;
for 1, -1 -> $player {
for @lines -> $line {
if @grid[$line[0 & 1 & 2]] == $player {
say "Player $player has won on line $line!";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment