{"id":1977,"date":"2022-12-14T00:02:40","date_gmt":"2022-12-13T23:02:40","guid":{"rendered":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/?p=1977"},"modified":"2022-12-14T00:02:40","modified_gmt":"2022-12-13T23:02:40","slug":"advent-of-code-with-openrefine-day-8","status":"publish","type":"post","link":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/2022\/12\/advent-of-code-with-openrefine-day-8\/","title":{"rendered":"Advent of Code with OpenRefine Day 8"},"content":{"rendered":"\n<p>This should have been relatively straightforward, and really was much simpler than <a href=\"http:\/\/www.meanboyfriend.com\/overdue_ideas\/2022\/12\/advent-of-code-with-openrefine-day-7\/\" data-type=\"post\" data-id=\"1975\">day 7<\/a> but my brain got stuck on some of the logic for the second part and then I made some stupid mistakes in applying transformations. Eventually I solved the problem with the example data from the description of the problem and checked I got the correct answer &#8211; then I was able to extract the transformation history and apply to the larger project &#8211; which was a nice use of that functionality in OpenRefine \ud83d\ude42<\/p>\n\n\n\n<p>The video below skips the actual code I used to work out part 2 so if you&#8217;re interested it looked a bit like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>with(rowIndex-row.record.fromRowIndex,position,\n  filter(\n    forEachIndex(\nrow.record.cells.treeHeight.value.slice(position+1),i,v,if(value&lt;=v,i+1,null)\n    )\n    ,j,j!=null)&#91;0]\n  )\n)<\/code><\/pre>\n\n\n\n<p>This code goes through a record tree heights (one record per column or row) and then finds all the trees either before or after the current position (this is what the &#8216;slice&#8217; does in the middle of this GREL) and then finds the position along from that of each taller tree in the list, and then extracts the first of those positions &#8211; which gives us the number of trees you can go along the row\/up or down the column before you find a tree the same size or bigger.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Advent of Code 2022 Day 8 using OpenRefine\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/lEzSQ_6-Rg8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This should have been relatively straightforward, and really was much simpler than day 7 but my brain got stuck on some of the logic for the second part and then I made some stupid mistakes in applying transformations. Eventually I solved the problem with the example data from the description of the problem and checked [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[104],"class_list":["post-1977","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-adventofcode2022"],"_links":{"self":[{"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/posts\/1977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/comments?post=1977"}],"version-history":[{"count":1,"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/posts\/1977\/revisions"}],"predecessor-version":[{"id":1978,"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/posts\/1977\/revisions\/1978"}],"wp:attachment":[{"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/media?parent=1977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/categories?post=1977"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.meanboyfriend.com\/overdue_ideas\/wp-json\/wp\/v2\/tags?post=1977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}