Last active
December 18, 2019 12:01
-
-
Save dckc/d58a04b154d44d46de9abcda84b2a2f0 to your computer and use it in GitHub Desktop.
Revisions
-
dckc revised this gist
Jul 22, 2019 . 1 changed file with 25 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,28 @@ """Simple fizzbuzz generator. The game proceeds with players announcing numbers increasing sequentially, except for multiples of 3 and 5: >>> usage = 'fizzbuzz 1 20' >>> from io import StringIO; stdout = StringIO() >>> main(usage.split(), stdout) >>> print(stdout.getvalue()) ... #doctest: +ELLIPSIS 1 2 fizz 4 buzz fizz 7 ... 14 fizzbuzz 16 ... """ def main(argv, stdout): -
dckc revised this gist
Jul 22, 2019 . 1 changed file with 13 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,15 +4,24 @@ def main(argv, stdout): [lo_, hi_] = argv[1:3] lo, hi = int(lo_), int(hi_) for word in fizzbuzz(lo, hi): print(word, file=stdout) def fizzbuzz(lo, hi): """ >>> list(fizzbuzz(1, 6)) [1, 2, 'fizz', 4, 'buzz'] """ for n in range(lo, hi): if n % 3 == 0 and n % 5 == 0: yield "fizzbuzz" elif n % 3 == 0: yield "fizz" elif n % 5 == 0: yield "buzz" else: yield n if __name__ == '__main__': -
dckc revised this gist
Jul 22, 2019 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ def main(argv, stdout): [lo_, hi_] = argv[1:3] lo, hi = int(lo_), int(hi_) for n in range(lo, hi): if n % 3 == 0 and n % 5 == 0: print("fizzbuzz", file=stdout) elif n % 3 == 0: -
dckc revised this gist
Jul 22, 2019 . 1 changed file with 12 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,21 @@ def main(argv, stdout): for n in range(int(argv[1]), int(argv[2])): if n % 3 == 0 and n % 5 == 0: print("fizzbuzz", file=stdout) elif n % 3 == 0: print("fizz", file=stdout) elif n % 5 == 0: print("buzz", file=stdout) else: print(n, file=stdout) if __name__ == '__main__': def _script_io(): from sys import argv, stdout main(argv, stdout) _script_io() -
dckc revised this gist
Jul 22, 2019 . 1 changed file with 16 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,17 @@ import sys def main(): for n in range(int(sys.argv[1]), int(sys.argv[2])): if n % 3 == 0 and n % 5 == 0: print("fizzbuzz") elif n % 3 == 0: print("fizz") elif n % 5 == 0: print("buzz") else: print(n) if __name__ == '__main__': main() -
dckc created this gist
Jul 22, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ import sys for n in range(int(sys.argv[1]), int(sys.argv[2])): if n % 3 == 0 and n % 5 == 0: print("fizzbuzz") elif n % 3 == 0: print("fizz") elif n % 5 == 0: print("buzz") else: print(n)