Live data from Hacker News

Fizz Buzz codegolf challenge in 15 languages

hackerrank.com

51–60 of 100 posts

Re: Fizz Buzz codegolf challenge in 15 languages

#51

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."

print(($_%3?"":Fizz).($_%5?"":Buzz)||$_,"\n")for 1..100

No need to quote the strings in some cases :-)

Re: Fizz Buzz codegolf challenge in 15 languages

#53

Earlier quoted context omitted.

`console.log` works fine.

What is wrong with this then (not my entry): process.stdin.resume(); process.stdin.setEncoding("ascii"); process.stdin.on("data", function (input) { var output = '' if (input % 3 === 0){ output += 'Fizz' } if (input % 5 === 0){ output += 'Buzz' } console.log(output || input) }); Testing locally with for(i=1;i gives the correct results.

There is no input. You have to print the desired result for all numbers between 1-100

Re: Fizz Buzz codegolf challenge in 15 languages

#56
71 characters (129 points) with JavaScript. I actually wrote this quite a while back (and have also posted it on HN before) - code golf is pretty fun every now and then!

    for(var i=0;i++
For anyone else interested in doing code golf with JavaScript, here's a goldmine of byte-saving techniques:

https://github.com/jed/140bytes/wiki/Byte-saving-techniques

Re: Fizz Buzz codegolf challenge in 15 languages

#57

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?

[deleted]

Re: Fizz Buzz codegolf challenge in 15 languages

#58
post #56

71 characters (129 points) with JavaScript. I actually wrote this quite a while back (and have also posted it on HN before) - code golf is pretty fun every now and then! for(var i=0;i++ For anyone else interested in doing code golf with JavaScript, here's a goldmine of byte-saving techniques: https://github.com/jed/140bytes/wiki/Byte-saving-techniques

Good, now everyone can just copy & paste it and the competition is a tie ;)

Re: Fizz Buzz codegolf challenge in 15 languages

#59

Earlier quoted context omitted.

What is wrong with this then (not my entry): process.stdin.resume(); process.stdin.setEncoding("ascii"); process.stdin.on("data", function (input) { var output = '' if (input % 3 === 0){ output += 'Fizz' } if (input % 5 === 0){ output += 'Buzz' } console.log(output || input) }); Testing locally with for(i=1;i gives the correct results.

There is no input. You have to print the desired result for all numbers between 1-100

Really? I just wasted 20 minutes trying to figure out whatever that boilerplate was supposed to receive :/
Post reply on HN