{"id":472,"date":"2012-02-11T10:35:05","date_gmt":"2012-02-11T15:35:05","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=472"},"modified":"2012-02-11T10:35:05","modified_gmt":"2012-02-11T15:35:05","slug":"saturday-morning-fun-with-cody","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2012\/02\/11\/saturday-morning-fun-with-cody\/","title":{"rendered":"Saturday morning fun with Cody"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p>Early this morning my wife found me in the family room, typing away at my laptop. She glimpsed this diagram on my screen and\r\n      asked if I was playing chess.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/cody\/eight-queens-sample-solution.png\"> <\/p>\r\n   <p>\"I'm doing MATLAB, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\">Cody<\/a>, and chess at the same time,\" I responded. She gave me the \"I have a weird husband\" look and left to get her coffee.\r\n   <\/p>\r\n   <p>You've probably heard of MATLAB and chess. If you haven't heard of Cody, it's an entertaining new ... umm ... game? ... on\r\n      MATLAB Central. How to describe it? Well, there are bite-size (byte-size?) MATLAB programming puzzles, 248 of them so far.\r\n      Then there are the players, almost 1,400 of them. Finally, there are the puzzle solutions, some 37,000 of them, created by\r\n      the players.\r\n   <\/p>\r\n   <p>I knew about the Cody project while it was under development, but I didn't pay too much attention to it until it went live\r\n      a couple of weeks ago. I tried it out for the first time on Ground Hog's Day, and by the weekend I was just about addicted.\r\n   <\/p>\r\n   <p>Here's a puzzle I solved just now. It was created by MathWorker and fellow blogger <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/players\/869436-doug-hull\">Doug Hull<\/a>, who has been creating Cody puzzles based on <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\">Project Euler<\/a>.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2012\/project-euler-screen-clip.png\"> <\/p>\r\n   <p>Suppose I click on the \"Solve This Now!\" button and try this solution:<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-bad-solution-screen-clip.png\"> <\/p>\r\n   <p>Then I will see that my solution has failed the test suite that Doug created for this problem.<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-failed-test-suite-screen-clip.png\"> <\/p>\r\n   <p>At this point I can think about what I did wrong and try again. (Readers, do you know what's wrong with my solution and how\r\n      to correct it?)\r\n   <\/p>\r\n   <p>Newcomers to Cody are eased into the game with simple puzzles like this:<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-add-two-numbers.png\"> <\/p>\r\n   <p>I could not resist entering this tongue-in-cheek solution:<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-add-two-numbers-fft.png\"> <\/p>\r\n   <p>Speaking of tongue-in-cheek, what do you think about <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/players\/1841757-the-cyclist\">the cyclist's<\/a> approach to <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/149-is-my-wife-right\">marriage<\/a> and to <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/167-pizza\">computing the volume of a common food item<\/a>? The cyclist can be <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/161-wilf-zeilberger-pairs\">serious<\/a>, too. There are already more than 150 puzzles created by the MATLAB community.\r\n   <\/p>\r\n   <p>Speaking of the MATLAB community, since I started writing this blog post, ten <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/306-eight-queens-solution-checker\/solutions\/map\">solutions<\/a> have already been entered for my new <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/306-eight-queens-solution-checker\">Eight Queens Solution Checker problem<\/a>.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2012\/eight-queens-solution-plot.png\"> <\/p>\r\n   <p>What's the matter with you people?? Don't you have anything better to do on Saturday morning? Oh ... wait ...<\/p>\r\n   <p>Anyway, I'm working on a set of Cody puzzles just for you, dear image processing blog readers. Stay tuned!<\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_f7290dedcf384dd5961a9b35cf207ba1() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='f7290dedcf384dd5961a9b35cf207ba1 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' f7290dedcf384dd5961a9b35cf207ba1';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Steve Eddins';\r\n        copyright = 'Copyright 2012 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_f7290dedcf384dd5961a9b35cf207ba1()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.13<br><\/p>\r\n<\/div>\r\n<!--\r\nf7290dedcf384dd5961a9b35cf207ba1 ##### SOURCE BEGIN #####\r\n%%\r\n% Early this morning my wife found me in the family room, typing away at my\r\n% laptop. She glimpsed this diagram on my screen and asked if I was playing\r\n% chess. \r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/cody\/eight-queens-sample-solution.png>>\r\n%\r\n% \"I'm doing MATLAB, <https:\/\/www.mathworks.com\/matlabcentral\/cody Cody>,\r\n% and chess at the same time,\" I responded. She gave me the \"I have a weird\r\n% husband\" look and left to get her coffee.\r\n%\r\n% You've probably heard of MATLAB and chess. If you haven't heard of Cody,\r\n% it's an entertaining new ... umm ... game? ... on MATLAB Central. How to\r\n% describe it? Well, there are bite-size (byte-size?) MATLAB programming\r\n% puzzles, 248 of them so far. Then there are the players, almost 1,400 of\r\n% them. Finally, there are the puzzle solutions, some 37,000 of them,\r\n% created by the players.\r\n%\r\n% I knew about the Cody project while it was under development, but I\r\n% didn't pay too much attention to it until it went live a couple of weeks\r\n% ago. I tried it out for the first time on Ground Hog's Day, and by the\r\n% weekend I was just about addicted.\r\n%\r\n% Here's a puzzle I solved just now. It was created by MathWorker and\r\n% fellow blogger\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/cody\/players\/869436-doug-hull\r\n% Doug Hull>, who has been creating Cody puzzles based on\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/cody Project Euler>.\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2012\/project-euler-screen-clip.png>>\r\n%\r\n% Suppose I click on the \"Solve This Now!\" button and try this solution:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-bad-solution-screen-clip.png>>\r\n%\r\n% Then I will see that my solution has failed the test suite that Doug\r\n% created for this problem.\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-failed-test-suite-screen-clip.png>>\r\n%\r\n% At this point I can think about what I did wrong and try again. (Readers,\r\n% do you know what's wrong with my solution and how to correct it?)\r\n%\r\n% Newcomers to Cody are eased into the game with simple puzzles like this:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-add-two-numbers.png>>\r\n%\r\n% I could not resist entering this tongue-in-cheek solution:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2012\/cody-add-two-numbers-fft.png>>\r\n%\r\n% Speaking of tongue-in-cheek, what do you think about\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/cody\/players\/1841757-the-cyclist\r\n% the cyclist's> approach to\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/149-is-my-wife-right\r\n% marriage> and to\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/167-pizza computing\r\n% the volume of a common food item>? The cyclist can be\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/161-wilf-zeilberger-pairs\r\n% serious>, too. There are already more than 150 puzzles created by the\r\n% MATLAB community.\r\n%\r\n% Speaking of the MATLAB community, since I started writing this blog post,\r\n% ten\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/306-eight-queens-solution-checker\/solutions\/map\r\n% solutions> have already been entered for my new <https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/306-eight-queens-solution-checker Eight Queens Solution\r\n% Checker problem>.\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2012\/eight-queens-solution-plot.png>>\r\n%\r\n% What's the matter with you people?? Don't you have anything better to do\r\n% on Saturday morning? Oh ... wait ...\r\n%\r\n% Anyway, I'm working on a set of Cody puzzles just for you, dear image\r\n% processing blog readers. Stay tuned!\r\n\r\n\r\n##### SOURCE END ##### f7290dedcf384dd5961a9b35cf207ba1\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Early this morning my wife found me in the family room, typing away at my laptop. She glimpsed this diagram on my screen and\r\n      asked if I was playing chess.\r\n   \r\n    \r\n   \"I'm doing... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2012\/02\/11\/saturday-morning-fun-with-cody\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/472"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=472"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/472\/revisions"}],"predecessor-version":[{"id":475,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/472\/revisions\/475"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}