Created
November 8, 2012 10:49
-
-
Save naohaq/4038114 to your computer and use it in GitHub Desktop.
FizzBuzz by sed script
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
#!/bin/sed -f | |
s/[05]$/& @Buzz/ | |
s/[12346789]$/& @/ | |
s/^[0-9]/@&/ | |
T | |
{ | |
:loop | |
s/@\([0-9]\)\(.* \)/\1@\2\1/ | |
T l1 | |
s/ 0/ / | |
s/ 1/ o/ | |
s/ 2/ oo/ | |
s/ 3/ ooo/ | |
s/ 4/ oooo/ | |
s/ 5/ ooooo/ | |
s/ 6/ oooooo/ | |
s/ 7/ ooooooo/ | |
s/ 8/ oooooooo/ | |
s/ 9/ ooooooooo/ | |
b loop | |
} | |
:l1 | |
s/ooo/x/g | |
s/^.*@.*x@/Fizz/ | |
s/^.*@.*o@Buzz/Buzz/ | |
s/@.*@// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment