Last active
December 20, 2015 04:19
-
-
Save Xom/6069846 to your computer and use it in GitHub Desktop.
fizzbuzz.pl
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
#!/usr/bin/env perl | |
use constant ANIMATE => 0; | |
use if ANIMATE, Time::HiRes => qw( usleep ); | |
$anim_delay = 10000; | |
$_ = 100; | |
$_ .= 'n'; | |
while (s/^0// | |
or s/z[0-9]/z/ | |
or s/[0-9]B/B/ | |
or s/0\?\?/0?Buzz/ | |
or s/5\?\?/2?Buzz/ | |
or s/\?\?/0?/ | |
or s/([258])0\?/2?$1/ | |
or s/([258])1\?/0?$1/ | |
or s/([258])2\?/1?$1/ | |
or s/([0369])([012])\?/$2?$1/ | |
or s/([147])0\?/1?$1/ | |
or s/([147])1\?/2?$1/ | |
or s/([147])2\?/0?$1/ | |
or s/[12]\?// | |
or s/0\?/Fizz/ | |
or s/0-/-9/ | |
or s/1-/0/ | |
or s/2-/1/ | |
or s/3-/2/ | |
or s/4-/3/ | |
or s/5-/4/ | |
or s/6-/5/ | |
or s/7-/6/ | |
or s/8-/7/ | |
or s/9-/8/ | |
or s/^([0-9]+)(n$)/$1-n\n$1??/m) | |
{ | |
if (ANIMATE) | |
{ | |
print "\n$_\n"; | |
usleep $anim_delay; | |
} | |
} | |
s/n\n//; | |
if (ANIMATE) | |
{ | |
print "\nResult:\n"; | |
} | |
print $_; | |
print "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment