Skip to content

Instantly share code, notes, and snippets.

@miau
Created May 12, 2013 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miau/5563798 to your computer and use it in GitHub Desktop.
Save miau/5563798 to your computer and use it in GitHub Desktop.
Google Code Jam 2013 - Qualification Round - Problem A. Tic-Tac-Toe-Tomek
use 5.012;
use warnings;
<>;
$/ = '';
my $c;
while (<>) {
print 'Case #' . ++$c . ': ';
s/\s+/ /g;
if (/[OT]{4}|[OT](?:...[OT]){3}|[OT](?:....[OT]){3}|[OT](?:.....[OT]){3}/) {
say 'O won';
} elsif (/[XT]{4}|[XT](?:...[XT]){3}|[XT](?:....[XT]){3}|[XT](?:.....[XT]){3}/) {
say 'X won';
} elsif (/\./) {
say 'Game has not completed';
} else {
say 'Draw';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment