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."
Fizz Buzz codegolf challenge in 15 languages
41–50 of 100 posts
Re: Fizz Buzz codegolf challenge in 15 languages
#42How 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.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
#43for(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
#44#define d printf(
main(i){i<101?(!(i%3)?d"Fizz"):0)|(!(i%5)?d"Buzz"):0)?d"\n"):d"%d\n",i),main(i+1):0;}
Re: Fizz Buzz codegolf challenge in 15 languages
#45Re: Fizz Buzz codegolf challenge in 15 languages
#46for 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
Even a little shorter :)
Re: Fizz Buzz codegolf challenge in 15 languages
#47 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
#48Login seems borked, but here's my Perl at 59 chars (141 points): print(($_%3?"":"Fizz").($_%5?"":"Buzz")||$_,"\n")for 1..100
say(("Fizz" if $_%%3)~("Buzz" if $_%%5)||$_) for 1..100Re: Fizz Buzz codegolf challenge in 15 languages
#49Login 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?
Re: Fizz Buzz codegolf challenge in 15 languages
#50for 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