Magnie

Unique FizzBuzz Solution

Oct 6th, 2014
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. # Magnie Mozios' Fizz Buzz program.
  2. # MagnieTheReal[at]gmail.com -- Copyright 2014 -- All Mine, except line 25.
  3. # Version 1.0 original, working, program.
  4. # Version 1.1 for cleaner output.
  5. __version__ = '1.1'
  6.  
  7. # Declare the characters.
  8. f = ord('f')
  9. i = ord('i')
  10. z = ord('z')
  11. b = ord('b')
  12. u = ord('u')
  13.  
  14. # Make writing 'zz' easier.
  15. zz = chr(z) * 2
  16.  
  17. # Add all the characters together to make a string.
  18. fizz = chr(f) + chr(i) + zz
  19. buzz = chr(b) + chr(u) + zz
  20.  
  21. # Declare the numbers, import math for necessary functions used in declarations.
  22. import math
  23. three = int((math.pi * 13.37)) / 14.0
  24. # Thanks to hobbes[at]fallingduck.net for this.
  25. five = float(int((math.acos(math.e - 2) * (math.pi ** 2)) - 2))
  26.  
  27. # Go through 1 to 100
  28. for i in xrange(1, 100):
  29.     # Print the result
  30.     print ''.join((  # Use tuple so input is one argument.
  31.         str(i) + ' ',  # Print the current number
  32.         (fizz) if not (i % three) else '',  # Print 'fizz' if divisible by 3.
  33.         (buzz) if not (i % five) else ''  # Print 'buzz' if divisible by 5.
  34.     ))
Advertisement
Add Comment
Please, Sign In to add comment