Last active
August 29, 2015 14:19
-
-
Save joar/e419abb25a5bd715cd82 to your computer and use it in GitHub Desktop.
Simple FizzBuzz in Python. Just kidding.
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 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()])); |
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 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