Skip to content

Instantly share code, notes, and snippets.

@ben-ng ben-ng/fizzbuzz.sh
Created Mar 4, 2019

Embed
What would you like to do?
FizzBuzz solved with data-flow programming in Bash.
#!/usr/bin/env bash
seq 1 100 | \
xargs -Ix -n1 echo "x + ((x % 3 == 0) + ((x % 5) == 0) * 2) * 1000" | \
bc | \
xargs -n1 printf "%04d\n" | \
sed 's/^1.*/Fizz/' | \
sed 's/^2.*/Buzz/' | \
sed 's/^3.*/FizzBuzz/' | \
sed 's/^0*//'
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.