Live data from Hacker News

Fizz Buzz codegolf challenge in 15 languages

hackerrank.com

41–50 of 100 posts

Re: Fizz Buzz codegolf challenge in 15 languages

#41

for(1..100){$_%15==0?print"FizzBuzz":$_%5==0?print"Buzz":$_%3==0?print"Fizz":print} Is my best perl golf so far... wrote this one eons ago. The site doesn't seem to work well however and it won't let me submit it. Would obviously be shorter with "say" instead of "print."

This is the expected output (http://cdn.hackerrank.com/fizzbuzz.txt)

Re: Fizz Buzz codegolf challenge in 15 languages

#42

How do you get javascript to work? I tried `process.stdout.write`, `console.log`, but the score is always zero. Other issues: - The "Solve FizzBuzz" button doesn't go anywhere if you are logged in, neither does "The Scenario" up top. - Forum doesn't work (please fill in all the required fields - they already are) - Signout link doesn't work

process.stdin.resume(); process.stdin.setEncoding('ascii');

process.stdin.on('data', function (input) { numbers = input.split("\n"); sum = parseInt(numbers[0]) + parseInt(numbers[1]) process.stdout.write(sum+"\n"); });

this is a sample code that takes a two digit integer and prints its sum. Can you use this format and see if it works?

Re: Fizz Buzz codegolf challenge in 15 languages

#43

for(1..100){$_%15==0?print"FizzBuzz":$_%5==0?print"Buzz":$_%3==0?print"Fizz":print} Is my best perl golf so far... wrote this one eons ago. The site doesn't seem to work well however and it won't let me submit it. Would obviously be shorter with "say" instead of "print."

    say (1..100).map({ $_ %% (3|5) ?? ("Fizz" if $_ %% 3) ~ ("Buzz" if $_ %% 5) !! $_ }).join("\n")
is my quick stab at a Perl 6 version. About the same length if I take out the spaces (which I'd rather not!).

Re: Fizz Buzz codegolf challenge in 15 languages

#46
post #37

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 :)

Some simple ways to cut down on characters: for i in range(1,101):print 'FizzBuzz' if not i%15 else 'Fizz' if not i%3 else 'Buzz' if not i%5 else i

for i in range(1,101): print "FizzBuzz" if not i % 15 else "Fizz" if not i % 3 else "Buzz" if not i % 5 else str(i)

Even a little shorter :)

Re: Fizz Buzz codegolf challenge in 15 languages

#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@?>====};:3W76543s1*N.-,l*)('&%$#"!~}|u;:xwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLKJIHGFEDCBA@?>=========};:3W76543s1*N.-,l*)('&%$#"!~}|u;:xwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLKJIHGFEDCBA@?>=======6;:3WV6543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLKJIHGFEDCBA@?>=====|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLK-IHGFEDCBA@?>==};:9870T43210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLKJIHGFEDCBA@?>=};:3W765432r0/.-,%I)(!&}CB"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLK-IHGFEDCBA@?>=========6Z:9876543210/.n,+*#G'&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLK-IHGFEDCBA@?>===6Z:9876543210/.-,+$H('&%$#"!~}|{zyxwvutsrqjonmlkjihgfedcb[!_X]VzZYXWV8TSRQPONMLKJIHGFED=aA@?>=6;:3WV6543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLKJIHGFEDCBA@?>==};4X87654321*/.-&J*)('&%$#"!~`v=======6;:3WV6543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLKJIHGFEDCBA@?>==|u;yxwvunsrqpi/glkjihgfedcba`_^]VzZYXWV8TSRQPONMLKJIHGFED=aA@?>=6;:3WV6543210/.n,+$H(h&%$#"!~}|{zs9Zvutm32ponmlkjihgfedcb[!_^W\[TxRQuUTSRQPO1lLKJIHGFEDCBA@?>=========6Z:9876543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPO1lLK-IHGFEDCBA@?>===========7[;49876543210/.-,+$H('&%$#"!~`|u;sxwvutsrqj0nmfkjiha'&dcb[!_^]\[ZYXWVUTSRQPONMLK-IHAeEDCBA@?!=

Re: Fizz Buzz codegolf challenge in 15 languages

#48

Login seems borked, but here's my Perl at 59 chars (141 points): print(($_%3?"":"Fizz").($_%5?"":"Buzz")||$_,"\n")for 1..100

Nice! Much better than my first stab. Slightly shorter (56 chars) P6 version:

   say(("Fizz" if $_%%3)~("Buzz" if $_%%5)||$_) for 1..100

Re: Fizz Buzz codegolf challenge in 15 languages

#49
post #38

Login seems borked, but here's my Perl at 59 chars (141 points): print(($_%3?"":"Fizz").($_%5?"":"Buzz")||$_,"\n")for 1..100

What happens on login?

I tried the github option, and the first time I tried, it barfed about "unauthorized credentials" or some such after the redirect back from github, bringing me to another hackerrank login page. I tried it again, and it choked right away with the same message. Third time and it asks to "Confirm Submission", but hung after hitting yes.

Re: Fizz Buzz codegolf challenge in 15 languages

#50

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 :)

for i in range(1,101): print "FizzBuzz" if i % 15 == 0 else "Fizz" if i % 3 == 0 else "Buzz" if i % 5 == 0 else str(i) derp, works better of course Though I can't find out the score the page to test the code seems to be inaccessible if you are signed in. It just redirects you to the signed in page and the signout link is broken. Still it's a fun and cool idea

for i in range(1,101):print i%15==0 and 'FizzBuzz' or i%3==0 and 'Fizz' or i%5==0 and 'Buzz' or i has a score of 102
Post reply on HN