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
#!/usr/bin/python2 # http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html # # Task: # # Write a program that prints the numbers from 1 to 100. # But for multiples of three print "Fizz" instead of the number and # for the multiples of five print "Buzz". For numbers which are multiples # of both three and five print "FizzBuzz". # from sys import stdout for i in range(0,101): divisible = False if i % 3 == 0: stdout.write("Fizz") divisible = True if i % 5 == 0: stdout.write("Buzz") divisible = True if not divisible: stdout.write(str(i)) stdout.write('\n') # This solution only uses 2 modulus operations to work, instead of the # original post which had to compute 4 modulus operations. # # Using stdout instead of print allows you to omit printing the trailing newline # character which the print function always prints, and makes it possible to # only use 2 modulus operations. # # If you have to output the number, then I think the cleanest way to do it is to # use the divisible variable. You can alternatively use nested if statements # instead of the divisible variable, but I think it's not as readable as the # above version. # # I think this solution is in the spirit of the task, especially since that # Fizz, Bang, and FizzBang are printed INSTEAD of the number, not along with it # as in the original post.
Title | Name | Language | UNIX | When |
---|---|---|---|---|
Re: Re: fizzbuzz.py | Cosmin | python | 1354141059 | 12 Years ago. |