Skip to content

Instantly share code, notes, and snippets.

@joar
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joar/e419abb25a5bd715cd82 to your computer and use it in GitHub Desktop.
Save joar/e419abb25a5bd715cd82 to your computer and use it in GitHub Desktop.
Simple FizzBuzz in Python. Just kidding.
import os; exec('def count_to_a_hundred():\n\tcursor = 1; max_ = 100;\n\twhile True:\n\t\tif not cursor <= max_:\n\t\t\traise StopIteration\n\t\tyield cursor; cursor += 1', globals(), locals()); open(os.path.join(os.path.dirname('__file__'), 'out.txt'), 'w').write('\n'.join([str('FizzBuzz' if (i % 5 == 0 and i % 3 == 0) else 'Buzz' if i % 5 == 0 else 'Fizz' if i % 3 == 0 else i) for i in count_to_a_hundred()]));
import os
exec('def count_to_a_hundred():\n'
'\tcursor = 1; max_ = 100;\n'
'\twhile True:\n'
'\t\tif not cursor <= max_:\n'
'\t\t\traise StopIteration\n'
'\t\tyield cursor; cursor += 1', globals(), locals())
open(os.path.join(os.path.dirname('__file__'), 'out.txt'), 'w').write(
'\n'.join(
[str('FizzBuzz' if (i % 5 == 0 and i % 3 == 0)
else 'Buzz' if i % 5 == 0
else 'Fizz' if i % 3 == 0 else i)
for i in count_to_a_hundred()]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment