FizzBuzz with Sather like loop

Posted by Shugo Maeda Fri, 24 Aug 2007 23:06:00 GMT

num = (1..100).each
fizz = ([""] * 2 + ["Fizz"]).cycle
buzz = ([""] * 4 + ["Buzz"]).cycle
loop do
  n = num.next
  puts (fizz.next + buzz.next).sub(/\A\z/) { n }
end

Leave a comment, View comments, View trackbacks

Your Comments.

Leave your own response

Other posts about this post.

This post has been discussed on the following web sites / blogs. If you wish to trackback to this post please use the following trackback address: http://blog.shugo.net/articles/trackback/25

Spread the word.

Shugo's Blog supports RSS (Real Simple Syndication), and Trackbacks from other blogs.

RSS feed for this post Trackback URI

Your Reply

Comment Form.

Fields denoted with a "*" are required.

You may also like to leave your email or website.