<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: Colin's Ruby Quiz #126 Submission</title>
    <link>http://blog.kineticweb.com/articles/2007/06/03/colins-ruby-quiz-126-submission</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>Colin's Ruby Quiz #126 Submission</title>
      <description>&lt;p&gt;If you haven&amp;#8217;t looked at this week&amp;#8217;s &lt;a href="http://www.rubyquiz.com"&gt;RubyQuiz&lt;/a&gt; yet, beware. Spoilers ahead.&lt;/p&gt;


	&lt;p&gt;This week&amp;#8217;s quiz was dead simple. But I think that&amp;#8217;s the point of this one. The most interesting thing about RubyQuiz for me is looking at how other people solved the same problem (no matter how simple) and learning about other ways to do things.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s my solution:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;(1..100).each do |n|
  ret = &amp;quot;&amp;quot;
  ret += &amp;quot;Fizz&amp;quot; if n.divmod(3).last == 0
  ret += &amp;quot;Buzz&amp;quot; if n.divmod(5).last == 0
  ret = n if ret == &amp;quot;&amp;quot;
  puts ret
end&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The challenge presented this week is one that is well suited for a quick in-interview coding session for potential hires. Having prospective employees write code was a new idea to me that I read about in Joel on Software. And although I didn&amp;#8217;t have candidates in the last round of hiring write code, I did review some psudo-code on the whiteboard with them and I think the next candidates will actually sit down at a machine and tap something out for us in our presence.&lt;/p&gt;</description>
      <pubDate>Sun, 03 Jun 2007 09:03:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:856fb621-0cd5-4488-9901-290971b38276</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/06/03/colins-ruby-quiz-126-submission</link>
      <category>ruby</category>
      <category>RubyQuiz</category>
      <category>Business</category>
      <trackback:ping>http://blog.kineticweb.com/articles/trackback/37</trackback:ping>
    </item>
    <item>
      <title>"Colin's Ruby Quiz #126 Submission" by Mat Schaffer</title>
      <description>I like this one much better:&lt;br /&gt;&lt;br /&gt;
1.upto(?d){|i,x|i%3&amp;lt;1&amp;&amp;x=:Fizz;puts i%5&amp;lt;1?"#{x}Buzz":x||i}
&lt;br /&gt;&lt;br&gt;
courtesy of &lt;br /&gt;&lt;a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/241505" rel="nofollow"&gt;http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/241505&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
(No I don't really think you should do this in an interview, but I love the absurdity of it :) ).</description>
      <pubDate>Sun, 03 Jun 2007 16:46:56 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:4fe8b6ae-2f5c-4124-b649-83b8b3b6aa17</guid>
      <link>http://blog.kineticweb.com/articles/2007/06/03/colins-ruby-quiz-126-submission#comment-60</link>
    </item>
    <item>
      <title>"Colin's Ruby Quiz #126 Submission" by AlSquire</title>
      <description>A one line and not very readable way :&lt;br /&gt;
&lt;code&gt;puts (1..100).map { |i| (ret = { "Fizz" =&gt; 3, "Buzz" =&gt; 5 }.map
 { |w, m| w if i % m == 0 }.join) == "" ? i : ret }&lt;/code&gt;</description>
      <pubDate>Sun, 03 Jun 2007 12:05:42 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:23603498-864c-41f2-a8a6-5c80bb02a107</guid>
      <link>http://blog.kineticweb.com/articles/2007/06/03/colins-ruby-quiz-126-submission#comment-59</link>
    </item>
    <item>
      <title>"Colin's Ruby Quiz #126 Submission" by AlSquire</title>
      <description>I would have used the % operator for modulo ( if n % 3 == 0 ).</description>
      <pubDate>Sun, 03 Jun 2007 11:28:27 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:7ca7c0f6-857b-45aa-bace-885b13978825</guid>
      <link>http://blog.kineticweb.com/articles/2007/06/03/colins-ruby-quiz-126-submission#comment-58</link>
    </item>
  </channel>
</rss>
