First commit of partial RosettaCode contents.

Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
Ingy döt Net 2013-04-08 13:02:41 -07:00
commit 1e05ecd7ee
781 changed files with 9080 additions and 0 deletions

View file

@ -0,0 +1,3 @@
for i in range(1, 101):
words = [word for n, word in ((3, 'Fizz'), (5, 'Buzz')) if not i % n]
print ''.join(words) or i

View file

@ -0,0 +1,4 @@
print ('\n'.join(''.join(''.join(['' if i%3 else 'Fizz',
'' if i%5 else 'Buzz'])
or str(i))
for i in range(1,101)))

View file

@ -0,0 +1,2 @@
for i in range(1, 101):
print 'Fizz'*(not(i%3))+'Buzz'*(not(i%5)) or i

View file

@ -0,0 +1,6 @@
messages = [None, "Fizz", "Buzz", "FizzBuzz"]
acc = 810092048
for i in xrange(1, 101):
c = acc & 3
print messages[c] if c else i
acc = acc >> 2 | c << 28

View file

@ -0,0 +1,14 @@
>>> ' '.join(''.join(''.join(['' if i%3 else 'F',
'' if i%5 else 'B'])
or str('00'))
for i in range(1,16))
'00 00 F 00 B F 00 00 F B 00 F 00 00 FB'
>>> _
'00 00 F 00 B F 00 00 F B 00 F 00 00 FB'
>>> _.replace('FB','11').replace('F','01').replace('B','10').split()[::-1]
['11', '00', '00', '01', '00', '10', '01', '00', '00', '01', '10', '00', '01', '00', '00']
>>> '0b' + ''.join(_)
'0b110000010010010000011000010000'
>>> eval(_)
810092048
>>>

View file

@ -0,0 +1,6 @@
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)]

View file

@ -0,0 +1,13 @@
from itertools import cycle, izip, count, islice
fizzes = cycle([""] * 2 + ["Fizz"])
buzzes = cycle([""] * 4 + ["Buzz"])
both = (f + b for f, b in izip(fizzes, buzzes))
# if the string is "", yield the number
# otherwise yield the string
fizzbuzz = (word or n for word, n in izip(both, count(1)))
# print the first 100
for i in islice(fizzbuzz, 100):
print i

View file

@ -0,0 +1,9 @@
for i in xrange(1, 101):
if i % 15 == 0:
print "FizzBuzz"
elif i % 3 == 0:
print "Fizz"
elif i % 5 == 0:
print "Buzz"
else:
print i