Skip to content

Instantly share code, notes, and snippets.

@yosmoc
Created June 26, 2016 20:06
Show Gist options
  • Save yosmoc/f39f3516744635f38bf2cc83c95742da to your computer and use it in GitHub Desktop.
Save yosmoc/f39f3516744635f38bf2cc83c95742da to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
def main():
for i in range(1, 101):
print(i)
if __name__ == '__main__':
main()
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