Skip to content

Instantly share code, notes, and snippets.

@naohaq

naohaq/fizzbuzz.sed

Created Nov 8, 2012
Embed
What would you like to do?
FizzBuzz by sed script
#!/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
You can’t perform that action at this time.