Created
March 4, 2019 05:39
-
-
Save ben-ng/6e98478161853c9c5f9898ad47df79b1 to your computer and use it in GitHub Desktop.
FizzBuzz solved with data-flow programming in Bash.
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 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