Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Some ruby code for those non-rubyists:

  (1..100) do |i|
    if i * 2 == 8 and i + 1 == 5
      puts "foo"
    elsif i + 3 == 9
      puts "bar"
    else 
      puts i
    end
  end
Not the solution, but all the syntax you'll need in there.


Probably should include the modulo operator too (Is it '%' ? I'm not a rubyist)


Part of the FizzBuzz test is to find out if the candidate is aware of modulo. :). But yeah it is %.


Oh man, I didn't even think of that. Such a basic concept...the mind reels. =(


I wouldn't really consider programmer == knows modulus. I only learned of the modulus operator a year or two ago (no formal CS background) and previously have built full scale web applications.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: