Skip to content

Instantly share code, notes, and snippets.

@boronology
Created July 21, 2012 23:38
Show Gist options
  • Select an option

  • Save boronology/3157549 to your computer and use it in GitHub Desktop.

Select an option

Save boronology/3157549 to your computer and use it in GitHub Desktop.
fizzbuzz wihtout string literal and division
#! /bin/usr/env python
# -*- coding:utf-8 -*-
import sys
z=sorted(str(sys.builtin_module_names))[-1]
b=sorted(str(sys.builtin_module_names))[231]
f=sorted(sys.copyright)[162]
i=sorted(sys.copyright)[186]
u=sorted(sys.copyright)[294]
#this heavily depends on Python environment
#at least this works well on Python 2.7.3 (Ubuntu 12.04)
fizz=f+i+z*2
buzz=b+u+z*2
fizzbuzz=range(1,16)
fizzbuzz[2]=fizzbuzz[5]=fizzbuzz[8]=fizzbuzz[11]=fizz
fizzbuzz[4]=fizzbuzz[9]=buzz
fizzbuzz[14]=fizz+buzz
for x in range(16,101):
if(type(fizzbuzz[x-16])==str):
fizzbuzz.append(fizzbuzz[x-16])
else:
fizzbuzz.append(x)
for x in fizzbuzz:print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment