A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Re: fizzbuzz.py - Stikked
From Cosmin, 12 Years ago, written in Python.
This paste is a reply to fizzbuzz.py from Gracious Capybara - view diff
Embed
  1. #!/usr/bin/python2
  2.  
  3. # http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html
  4. #
  5. # Task:
  6. #
  7. # Write a program that prints the numbers from 1 to 100.
  8. # But for multiples of three print "Fizz" instead of the number and
  9. # for the multiples of five print "Buzz". For numbers which are multiples
  10. # of both three and five print "FizzBuzz".
  11. #
  12.  
  13. from sys import stdout
  14.  
  15. for i in range(0,101):
  16.     divisible = False
  17.  
  18.     if i % 3 == 0:
  19.         stdout.write("Fizz")
  20.         divisible = True
  21.  
  22.     if i % 5 == 0:
  23.         stdout.write("Buzz")
  24.         divisible = True
  25.    
  26.     if not divisible:
  27.         stdout.write(str(i))
  28.        
  29.     stdout.write('\n')
  30.    
  31. # This solution only uses 2 modulus operations to work, instead of the
  32. # original post which had to compute 4 modulus operations.
  33. #
  34. # Using stdout instead of print allows you to omit printing the trailing newline
  35. # character which the print function always prints, and makes it possible to
  36. # only use 2 modulus operations.
  37. #
  38. # If you have to output the number, then I think the cleanest way to do it is to
  39. # use the divisible variable.  You can alternatively use nested if statements
  40. # instead of the divisible variable, but I think it's not as readable as the
  41. # above version.
  42. #
  43. # I think this solution is in the spirit of the task, especially since that
  44. # Fizz, Bang, and FizzBang are printed INSTEAD of the number, not along with it
  45. # as in the original post.

Replies to Re: fizzbuzz.py rss

Title Name Language When
Re: Re: fizzbuzz.py Cosmin python 12 Years ago.