Skip to content

Instantly share code, notes, and snippets.

@masak
Created September 8, 2010 08:09
Show Gist options
  • Save masak/569803 to your computer and use it in GitHub Desktop.
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