Skip to content

Instantly share code, notes, and snippets.

@touzoku
Created January 30, 2013 13:39
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 touzoku/4673372 to your computer and use it in GitHub Desktop.
Save touzoku/4673372 to your computer and use it in GitHub Desktop.
Problem solution for "Balanced smileys" at Facebook Hacker Cup 2013 Qualification round. https://www.facebook.com/hackercup/problems.php?pid=403525256396727&round=185564241586420
use strict;
use warnings;
use 5.10.00;
my $regexp = qr/
^(
(?:
[a-z :]|:\(|:\)|\((?1)\)
)*
)$
/x;
<>;
my $i;
for(<>){
$i++;
say /$regexp/?"Case #$i: YES":"Case #$i: NO";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment