Live data from Hacker News

Fizz Buzz codegolf challenge in 15 languages

hackerrank.com

91–100 of 100 posts

Re: Fizz Buzz codegolf challenge in 15 languages

#91
post #90

Earlier quoted context omitted.

74 for i in range(1,101):print(''if i%3 else'Fizz')+(''if i%5 else'Buzz')or i

70 now, still same idea. for x in range(1,101):print['','Fizz'][x%3==0]+['','Buzz'][x%5==0]or x

Excellent. Down to 68.

    for x in range(1,101):print['','Fizz'][x%3

Re: Fizz Buzz codegolf challenge in 15 languages

#92
post #68

for i in range(1,101): print "FizzBuzz" if i %3 == 0 and i % 5 == 0 else "Fizz" if i % 3 == 0 else "Buzz" if i % 5 == 0 else str(i) Scores 69 in python but the login/signup is broken :)

OK I cheated and used google and found (60 chars): for i in range(1,101):print'FizzBuzz'[i*i%3*4:8--i**4%5]or i Pastebin of my explanation: http://pastebin.com/raw.php?i=00Db30FF EDIT: ugh, sometimes I hate markdown, moved post to pastebin.

Awesomely ingenious use of math above. 59 if newlines count as 1.

    i=1
    while i

Re: Fizz Buzz codegolf challenge in 15 languages

#94
post #47

My best malbolge version: bCBA@?>= = = = = = = |{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLK-CgGFEDCBA@?>= = = = 7 = = =};:9876543210/.-,+*)('&%$#"!~}|u;sxwvutsrqj0nmfkjiha'&dcb[!_^]V[ZYXWVUTSRQPONMLKJIBfFEDCBA@?>=};:9870T43210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLKJIHGFEDCBA@?>=};:3W765432r0/.-,%I)(!&}CB"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLK-IHGFEDCBA@?>= = = =};:3W76…

I'd never heard of malbolge until last night, when it played a role in the mystery on CBS' "Elementary" (an excellent series, BTW). Kind of weird to encounter such an obscure language twice in under 24 hours.

Re: Fizz Buzz codegolf challenge in 15 languages

#95
post #68

for i in range(1,101): print "FizzBuzz" if i %3 == 0 and i % 5 == 0 else "Fizz" if i % 3 == 0 else "Buzz" if i % 5 == 0 else str(i) Scores 69 in python but the login/signup is broken :)

OK I cheated and used google and found (60 chars): for i in range(1,101):print'FizzBuzz'[i*i%3*4:8--i**4%5]or i Pastebin of my explanation: http://pastebin.com/raw.php?i=00Db30FF EDIT: ugh, sometimes I hate markdown, moved post to pastebin.

Should have been empty string f[4:4]

Re: Fizz Buzz codegolf challenge in 15 languages

#96
post #90

Earlier quoted context omitted.

70 now, still same idea. for x in range(1,101):print['','Fizz'][x%3==0]+['','Buzz'][x%5==0]or x

Excellent. Down to 68. for x in range(1,101):print['','Fizz'][x%3

My shortest Python solution is 59 characters. Two tricks, use while instead of range, and use string repetition instead of lists

  n=1
  while n
And here is a wacky one in 96 chars

  w=range(101)
  w[::3]=['Fizz']*34
  w[::5]=['Buzz']*21
  w[::15]=['FizzBuzz']*7
  for s in w[1:]:print s

Re: Fizz Buzz codegolf challenge in 15 languages

#97
post #68

Earlier quoted context omitted.

OK I cheated and used google and found (60 chars): for i in range(1,101):print'FizzBuzz'[i*i%3*4:8--i**4%5]or i Pastebin of my explanation: http://pastebin.com/raw.php?i=00Db30FF EDIT: ugh, sometimes I hate markdown, moved post to pastebin.

Awesomely ingenious use of math above. 59 if newlines count as 1. i=1 while i

Much simpler solution in 59 chars

  n=1
  while n

Re: Fizz Buzz codegolf challenge in 15 languages

#98

Earlier quoted context omitted.

Excellent. Down to 68. for x in range(1,101):print['','Fizz'][x%3

My shortest Python solution is 59 characters. Two tricks, use while instead of range, and use string repetition instead of lists n=1 while n And here is a wacky one in 96 chars w=range(101) w[::3]=['Fizz']*34 w[::5]=['Buzz']*21 w[::15]=['FizzBuzz']*7 for s in w[1:]:print s

You can save one more character with an exec loop

  n=1;exec"print'Fizz'*(n%3

Re: Fizz Buzz codegolf challenge in 15 languages

#99
post #68

Earlier quoted context omitted.

OK I cheated and used google and found (60 chars): for i in range(1,101):print'FizzBuzz'[i*i%3*4:8--i**4%5]or i Pastebin of my explanation: http://pastebin.com/raw.php?i=00Db30FF EDIT: ugh, sometimes I hate markdown, moved post to pastebin.

Awesomely ingenious use of math above. 59 if newlines count as 1. i=1 while i

I came up with a shorter way to write the first index!

  n%-3&4
unbelievably it works
Post reply on HN