Forum: Ruby Solution to 126

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A81805e545b4996b36c7d011a5249b2c?d=identicon&s=25 Justin Ethier (Guest)
on 2007-06-04 18:40
(Received via mailing list)

Here is my solution. I made the assumption that the interviewer has a
terminal handy and I have 5-10 minutes to crank this out. If I was just
writing it down on paper, I made a note of a couple things that I got
before I had a chance to see the output:

for i in 1...101 # was 100 before checking this
  out = ''
  out = out + 'Fizz' if (i % 3) == 0
  out = out + 'Buzz' if (i % 5) == 0
  out = i.to_s if (out.size) == 0

  print out + "\n" # Original did not have a newline


This topic is locked and can not be replied to.