{"id":255,"date":"2014-02-05T20:44:37","date_gmt":"2014-02-05T20:44:37","guid":{"rendered":"http:\/\/www.45rpmsoftware.com\/wordpress\/?p=255"},"modified":"2014-02-07T15:52:24","modified_gmt":"2014-02-07T15:52:24","slug":"fizzbuzz","status":"publish","type":"post","link":"https:\/\/www.45rpmsoftware.com\/blog\/?p=255","title":{"rendered":"FizzBuzz"},"content":{"rendered":"<p>Did you ever play FizzBuzz? If you didn\u2019t, it\u2019s a drinking game. That\u2019s how I learned it, anyway.<\/p>\n<p>It\u2019s a counting game, and the rules are simple enough. Everyone sits in a circle and takes it in turn to say the next number, starting from one and ending at 100. The catch is that if the number is divisible by three the player says Fizz instead of the number, and if the number is divisible by five the player says Buzz. If the number is divisible by three and five the player says FizzBuzz. The penalty for miscounting, mis-fizzing or mis-buzzing is, predictably, a drink. Easy? Surprisingly not, and really rather hard after a skinful.<\/p>\n<p><!--more-->It\u2019s also a game that\u2019s popular with interviewers as a programming assignment to weed out applicants who are non-programming chancers.<\/p>\n<p>A friend sent me an email that amused me greatly the other day. It\u2019s the solution to FizzBuzz, but Enterprise quality code. You can download it here: <a href=\"https:\/\/github.com\/EnterpriseQualityCoding\/FizzBuzzEnterpriseEdition\">https:\/\/github.com\/EnterpriseQualityCoding\/FizzBuzzEnterpriseEdition<\/a><\/p>\n<p>It\u2019s a joke, but (sadly) there\u2019s more than a grain of truth in it.<\/p>\n<p>For completeness, here\u2019s my answer (in C, natch). I\u2019d be very interested to here from anyone who has a faster, more efficient, solution.<\/p>\n<pre>#include &lt;stdio.h&gt;\r\nint main() {\u00a0\r\n    for (int i=1; i&lt;=100; i++) \r\n        ((i%3!=0)&amp;&amp;(i%5!=0))?printf(\"%d\\n\",i):printf(\"%s%s\\n\",(i%3==0)?\u201dFizz\":\"\",(i%5==0)?\u201dBuzz\":\"\");\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Did you ever play FizzBuzz? If you didn\u2019t, it\u2019s a drinking game. That\u2019s how I learned it, anyway. It\u2019s a counting game, and the rules are simple enough. Everyone sits in a circle and takes it in turn to say the next number, starting from one and ending at 100. The catch is that if &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.45rpmsoftware.com\/blog\/?p=255\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;FizzBuzz&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/255"}],"collection":[{"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=255"}],"version-history":[{"count":0,"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/255\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.45rpmsoftware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}