今更FizzBuzz

テストも併せて10分くらい。id:kuenishiの脳みそのレベルが知れますね;)

for n in range(1,101):
    str = ''
    if not n%3: str += 'Fizz'
    if not n%5: str += 'Buzz'
    if n%3 and n%5: str = n.__str__()
    print str

(追記)
もちょっと短く美しくなった(整然)。

for n in range(1,101):
  s=''
  if not n%3:s+='Fizz'
  if not n%5:s+='Buzz'
  print s or n

初めてのPython 第2版

初めてのPython 第2版

FizzBuzzこれで最後

best="""for i in range(1,101):print'Fizz'*(i%3<1)+'Buzz'*(i%5<1)or i"""
str="""for n in range(1,101):print(((n%3<1 and 'Fizz')or'')+((n%5<1 and 'Buzz')or''))or n"""

exec str
print "length of the code:", len(str)
print "length of the best:", len(best)

bestのコードはすごいね。60バイト。つーか*(アスタリスク)で論理積になるなんて知らねーよ普通(もしかして常識?)。

(追記)
56バイトという超人がイタ