| import random | |
| for i in range(0, 100): | |
| if not i % 15: | |
| random.seed(1178741599) | |
| print [i+1, "Fizz", "Buzz", "FizzBuzz"][random.randint(0,3)] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
ChuntaoLu
commented
Jan 7, 2014
|
Interesting code. How do you find the right seed |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
pyrtsa
Apr 10, 2014
Brute force?
def f(i):
random.seed(i)
return [random.randint(0, 3) for _ in range(15)]
xs = [1, 0, 0, 3, 3, 1, 3, 2, 0, 2, 1, 0, 3, 3, 0]
next(i for i in itertools.count() if f(i) == xs) # runs for a long time
# PS. To save the wait, try e.g.:
# next(i for i in itertools.count(1178700000) if f(i) == xs)
pyrtsa
commented
Apr 10, 2014
|
Brute force? def f(i):
random.seed(i)
return [random.randint(0, 3) for _ in range(15)]
xs = [1, 0, 0, 3, 3, 1, 3, 2, 0, 2, 1, 0, 3, 3, 0]
next(i for i in itertools.count() if f(i) == xs) # runs for a long time
# PS. To save the wait, try e.g.:
# next(i for i in itertools.count(1178700000) if f(i) == xs) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
wasuaje
Apr 16, 2015
Vintage style, hahahha
for i in range(1,11):
if i % 3 == 0:
print "fizz"
elif i % 5 == 0:
print "buzz"
elif i % 3 == 0 and i % 5 == 0:
print "fizz buzz"
else
print i
wasuaje
commented
Apr 16, 2015
|
Vintage style, hahahha for i in range(1,11):
if i % 3 == 0:
print "fizz"
elif i % 5 == 0:
print "buzz"
elif i % 3 == 0 and i % 5 == 0:
print "fizz buzz"
else
print i
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
fisadev
Apr 20, 2015
That last one doesn't work. For numbers which are both divisible by 3 and 5, it prints only "fizz", not "fizz buzz" as it should.
fisadev
commented
Apr 20, 2015
|
That last one doesn't work. For numbers which are both divisible by 3 and 5, it prints only "fizz", not "fizz buzz" as it should. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
jjconti
commented
Apr 21, 2015
|
And there is a missing ':' after the 'else' keyword. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
parkeristyping
Aug 31, 2016
import requests
print requests.get("https://s3.amazonaws.com/fizzbuzz/output").content
parkeristyping
commented
Aug 31, 2016
import requests
print requests.get("https://s3.amazonaws.com/fizzbuzz/output").content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting code. How do you find the right seed
1178741599?