{"id":3986,"date":"2016-08-11T18:47:54","date_gmt":"2016-08-11T22:47:54","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=3986"},"modified":"2016-08-11T18:50:41","modified_gmt":"2016-08-11T22:50:41","slug":"prettier-cody-code","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2016\/08\/11\/prettier-cody-code\/","title":{"rendered":"Prettier Cody Code!"},"content":{"rendered":"<p>We did some web updates last night, and <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/\">Cody<\/a> emerged with a fresh coat of paint. As a result it&#8217;s more mobile-friendly. The tags for each problem are a little more prominent on the right side. But I especially want to call your attention to the fact that\u00a0code regions\u00a0now feature proper MATLAB syntax highlighting.<\/p>\n<p>I want to show you what it looks like with\u00a0a problem that <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/players\/869215-john-d-errico\">John D&#8217;Errico<\/a> created a few weeks ago. The problem, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/42914-counting-the-grand-primes\">Counting the Grand Primes<\/a>, asks you to look for prime pairs that differ by exactly 1000.\u00a0The leading answer is by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/players\/2951682-peng-liu\">Peng Liu<\/a>.<\/p>\n<p><strong>Spoiler Alert!<\/strong> If you haven&#8217;t solved this problem yet, you wouldn&#8217;t ordinarily be allowed to look at this solution. But I&#8217;m going to show you anyway, because it&#8217;s a nice solution and a good illustration of the new feature.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"666\" height=\"133\" class=\"alignnone size-full wp-image-3990\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/peng2.png\" alt=\"peng2\" \/><\/p>\n<p>Ooh! Line numbers! Notice\u00a0that the keywords &#8220;function&#8221; and &#8220;end&#8221; are\u00a0blue and the comments are green. Thoughtfully,\u00a0Peng has provided not just one, but three solutions. Two of them excel\u00a0in the Cody sense: they don&#8217;t use\u00a0a lot of code. But we all know there&#8217;s more to life than being short. The first one runs faster\u00a0because you compute the\u00a0prime numbers once rather than twice. Since two of the solutions are commented out, they appear in green.<\/p>\n<p>If you do a lot of MATLAB programming, you&#8217;ll appreciate how important syntax highlighting is to your coding practice. It should make it easier to create and interpret solutions.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/peng2.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>We did some web updates last night, and Cody emerged with a fresh coat of paint. As a result it&#8217;s more mobile-friendly. The tags for each problem are a little more prominent on the right side&#8230;. <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2016\/08\/11\/prettier-cody-code\/\">read more >><\/a><\/p>\n","protected":false},"author":69,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[250],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/3986"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/69"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=3986"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/3986\/revisions"}],"predecessor-version":[{"id":3994,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/3986\/revisions\/3994"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=3986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=3986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=3986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}