Skip to content

Instantly share code, notes, and snippets.

@alexpirine
Last active December 19, 2015 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpirine/5959159 to your computer and use it in GitHub Desktop.
Save alexpirine/5959159 to your computer and use it in GitHub Desktop.
FizzBuzz
# 1 min 20 s (including login and tests)
for k in range(1, 101):
if not k % 3 and not k % 5:
print "FizzBuzz"
elif not k % 3:
print "Fizz"
elif not k % 5:
print "Buzz"
else:
print k
# 15 min (after several trials, trying to avoid code redundancy)
for k in range(1, 101):
l = '%d' % k
r = [{0: 'Fizz'}.get(k % 3, l), {0: 'Buzz'}.get(k % 5, l)]
if l in r:
r.remove(l)
print ''.join(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment