{"id":15,"date":"2008-10-02T14:20:04","date_gmt":"2008-10-02T18:20:04","guid":{"rendered":"https:\/\/blogs.mathworks.com\/videos\/2008\/10\/02\/review-of-spiral-puzzler\/"},"modified":"2009-05-19T16:43:08","modified_gmt":"2009-05-19T16:43:08","slug":"review-of-spiral-puzzler","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/videos\/2008\/10\/02\/review-of-spiral-puzzler\/","title":{"rendered":"Review of spiral puzzler"},"content":{"rendered":"In the recent <a href=\"https:\/\/blogs.mathworks.com\/videos\/2008\/09\/25\/puzzler-cleverness-needed\/\">Puzzler about the spiral<\/a>, most of the code that was produced went along the following:\r <ol>\r \t<li>Create the spiral matrix<\/li>\r \t<li>Find the indices of the &#8216;1&#8217;s in the binary targets matrix<\/li>\r \t<li>Find the values of the spiral matrix at the indices from step 2<\/li>\r \t<li>Choose the lowest value and corresponding indices from step 3<\/li>\r \t<li>Create a look-up table for the deltaX and deltaY<\/li>\r \t<li>Use the indices from step 4 in the look-up tables<\/li>\r \t<li>Deal with the edge case<\/li>\r <\/ol>\r Most of these steps have been taught in the abstract at some point in the movies from this blog.  Let&#8217;s review the skills used in the above algorithm.  The second movie below is <strong>new<\/strong> content.\r \r 1.) <strong>Create the spiral matrix<\/strong>\r This is just a matter of typing out the matrix.  This is covered incidentally in many videos.\r \r 2.) <strong>Find the indices of the &#8216;1&#8217;s in the binary targets matrix<\/strong>\r \r 3.) <strong>Find the values of the spiral matrix at the indices from step 2<\/strong>\r \r The video on Absolute and Logical indexing covers these two steps.  The most relevant part starts at 3:50.\r \r <\/br> <div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"3877438792001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div> <\/br>\r \r 4.) <strong>Choose the lowest value and corresponding indices from step 3<\/strong>\r The MIN function works well here.\r \r 5.) <strong>Create a look-up table for the deltaX and deltaY<\/strong>\r This is a specialized matrix created most often with REPMAT.  I cover how to make this look-up without REPMAT here along with other matrix creation skills in this new video.\r \r <div><div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"3877438789001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div><\/div>\r \r 6.) <strong>Use the indices from step 4 in the look-up tables<\/strong>\r This is covered in the same video as step 2.\r \r 7.) <strong>Deal with the edge case<\/strong>\r This is covered with an IF THEN statement.  I made a video about SWITCH CASE statements that started out with IF THEN statements then converted them when it made better code.\r \r <\/br> <div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"3877438056001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div> <\/br>","protected":false},"excerpt":{"rendered":"<div class=\"thumbnail thumbnail_asset asset_overlay video\"><a href=\"https:\/\/blogs.mathworks.com\/videos\/2008\/10\/02\/review-of-spiral-puzzler\/?dir=autoplay\"><img decoding=\"async\" src=\"https:\/\/cf-images.us-east-1.prod.boltdns.net\/v1\/static\/62009828001\/ccd3c814-c933-4d4c-bba7-3f5f41786465\/96ae7952-fab7-43e0-8974-4804575c12ef\/160x90\/match\/image.jpg\" onError=\"this.style.display ='none';\"\/>\n      <div class=\"overlay_container\">\n      <span class=\"icon-video icon_color_null\"><time class=\"video_length\">4:29<\/time><\/span>\n      <\/div>\n      <\/a><\/div><p>In the recent Puzzler about the spiral, most of the code that was produced went along the following:\r \r \tCreate the spiral matrix\r \tFind the indices of the &#8216;1&#8217;s in the binary targets&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/videos\/2008\/10\/02\/review-of-spiral-puzzler\/\">read more >><\/a><\/p>","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,17,10],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}