Created
May 17, 2012 07:31
-
-
Save anonymous/2717193 to your computer and use it in GitHub Desktop.
Regex of inverse fizzbuzz.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Test::More; | |
my $reg_inv_fizzbuz = qr/^( | |
(((((F?B)?F)?F)?B)?F)?Z | |
(FBFFBFZ)* | |
(F|FB|FBF|FBFF|FBFFB|FBFFBF) | |
|(((((F?B)?F)?F)?B)?F)?Z | |
|((((F?B)?F)?F)?B)?F | |
|(((F?B)?F)?F)?B | |
|((F?B)?F)?F | |
|(F?B)?F | |
|F?B | |
|F | |
)$/x; | |
like 'F' => $reg_inv_fizzbuz; | |
like 'B' => $reg_inv_fizzbuz; | |
like 'FB' => $reg_inv_fizzbuz; | |
like 'BF' => $reg_inv_fizzbuz; | |
like 'FFB' => $reg_inv_fizzbuz; | |
like 'FF' => $reg_inv_fizzbuz; | |
like 'FBF' => $reg_inv_fizzbuz; | |
like 'ZF' => $reg_inv_fizzbuz; | |
unlike 'BFB' => $reg_inv_fizzbuz; | |
like 'ZFBFFBFZFBFFBFZFBF' => $reg_inv_fizzbuz; | |
unlike 'ZFBFFBFZFBFFBFZFF' => $reg_inv_fizzbuz; | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment