{"id":103,"date":"2021-04-20T21:48:53","date_gmt":"2021-04-20T21:48:53","guid":{"rendered":"http:\/\/jl.bibaud.com\/?p=103"},"modified":"2022-06-15T01:59:46","modified_gmt":"2022-06-15T01:59:46","slug":"how-many-4-block-rectangles-in-a-10-by-10-grid","status":"publish","type":"post","link":"https:\/\/jl.bibaud.com\/index.php\/2021\/04\/20\/how-many-4-block-rectangles-in-a-10-by-10-grid\/","title":{"rendered":"How many 4 block rectangles in a 10 by 10 grid?"},"content":{"rendered":"\n<p>The rules given with this question were simple; you have a 10 by 10 grid in which you can place 4 block-long rectangles horizontally or vertically. Similar to this: <\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image.png\" alt=\"\" class=\"wp-image-134\" width=\"370\" height=\"328\" srcset=\"https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image.png 1017w, https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image-300x266.png 300w, https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image-768x682.png 768w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>Try it!<\/p>\n\n\n\n<p>So a very simple and straightforward idea is to place every block in every possible direction using pyhton, and this is exactly what the program does.<\/p>\n\n\n\n<p>Using recursion, it is given a grid (empty at first), I then find the next empty block, and try to fill it with a horizontal set of n blocks (n being 4 in this case). It checks that there are 4 blocks of space inside the grid but also for any already used block, because it may be already set by a verticle set previously. If it can&#8217;t place a horizontal set of blocks it will test and set a vertical one. When placing a new set of blocks it then calls the function again with the new grid. If neither a horizontal or vertical set can be placed it quits the function. Before placing anything I do a test to check if it&#8217;s complete such as to get the possibility.<\/p>\n\n\n\n<p>Well as it seems, a 10 by 10 grid is impossible to fill with 4by1 set of blocks. There is a simple way of looking at why, <a rel=\"noreferrer noopener\" href=\"https:\/\/youtu.be\/PbJaOaXthhk?t=50\" data-type=\"URL\" data-id=\"https:\/\/youtu.be\/PbJaOaXthhk?t=50\" target=\"_blank\">this explains the method<\/a>.<\/p>\n\n\n\n<p>A few things that I can do is change the size of the grid to something possible and get a nice result that way.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"467\" height=\"849\" src=\"https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image-3.png\" alt=\"\" class=\"wp-image-137\" srcset=\"https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image-3.png 467w, https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image-3-165x300.png 165w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><figcaption>The first possibility from my code<\/figcaption><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jl.bibaud.com\/wp-content\/uploads\/2021\/04\/image-1-e1618954695295.png\" alt=\"\" class=\"wp-image-135\" width=\"298\" height=\"519\"\/><figcaption>A nicer possibility<\/figcaption><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>To conclude, this was a fun quick recursion problem. I definitely like the end display. A few optimizations could be done, like when calling the function again I parse through the last position occupied to not loop from the start to the next empty block but, really there is no need because it&#8217;s just for fun.<\/p>\n\n\n\n<p>Hope you enjoyed. Byeee!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The rules given with this question were simple; you have a 10 by 10 grid in which you can place 4 block-long rectangles horizontally or vertically. Similar to this: Try it! So a very simple and straightforward idea is to place every block in every possible direction using pyhton, and this is exactly what the&hellip;&nbsp;<a href=\"https:\/\/jl.bibaud.com\/index.php\/2021\/04\/20\/how-many-4-block-rectangles-in-a-10-by-10-grid\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">How many 4 block rectangles in a 10 by 10 grid?<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":134,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","cybocfi_hide_featured_image":"","footnotes":""},"categories":[26,2],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-project"],"_links":{"self":[{"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":10,"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions\/160"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/media\/134"}],"wp:attachment":[{"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jl.bibaud.com\/index.php\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}