Created
June 26, 2016 20:06
-
-
Save yosmoc/f39f3516744635f38bf2cc83c95742da to your computer and use it in GitHub Desktop.
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 python | |
def main(): | |
for i in range(1, 101): | |
print(i) | |
if __name__ == '__main__': | |
main() |
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
import subprocess | |
def main(): | |
p = subprocess.Popen(['./count.py'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) | |
while 1: | |
output = p.stdout.readline() | |
print(output) | |
if not output: | |
break | |
if fizzbuzz(int(output)) != int(output): | |
p.stdin.write(fizzbuzz(int(output)).encode('utf-8')) | |
def fizzbuzz(number): | |
if number % 15 == 0: | |
return 'fizzbuzz' | |
elif number % 3 == 0: | |
return 'fizz' | |
elif number % 5 == 0: | |
return 'buzz' | |
else: | |
return number | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment