Some doctors watch Grey’s Anatomy to relax, and some engineers code for fun when they’re not coding. Well, those engineers are us.
Ben P. decided to kick off an internal game of code golf , which we’re hoping will be the first of many. The objective is to solve a certain problem with the fewest number of characters.
SPOILER ALERT: solutions are at the bottom of this post.
Problem 1: implement FizzBuzz:
but replace multiples of 3 with “Fizz”
and multiples of 5 with “Buzz”
and multiples of both with “FizzBuzz”.
(each output should be on a new line)
A couple points for clarification: the output needs to be exactly as specified – no extraneous quotation marks. You also can’t rely on the user having an internet connection or anything other than ruby 1.8.7 installed (including bash).
Ben gave the team a 4-day deadline. The next day, he announced updates: Alex P. was at 34 characters “although it might break the rules.” Gareth was at 63 characters with a normal ruby program.
The winning code was 57 characters long. Below is a 58-character solution we found that does some interesting things, and the internet record is 50 characters. Can you beat that?
58- character solution: