{"id":1247,"date":"2020-12-04T16:46:32","date_gmt":"2020-12-04T15:46:32","guid":{"rendered":"http:\/\/www.thelins.se\/johan\/blog\/?p=1247"},"modified":"2020-12-04T16:46:32","modified_gmt":"2020-12-04T15:46:32","slug":"advent-of-code-and-learning","status":"publish","type":"post","link":"https:\/\/www.thelins.se\/johan\/blog\/2020\/12\/advent-of-code-and-learning\/","title":{"rendered":"Advent of Code and Learning"},"content":{"rendered":"\n<p>So, I decided to do <a href=\"https:\/\/adventofcode.com\/\">Advent of Code<\/a> this year too. I usually get stuck part of the way, but I still think that it is a fun exercise.<\/p>\n\n\n\n<p>This year the plan is to use python and pytest the whole way through. Every day that i learn something that I want to remember, I add a <code>til.txt<\/code> file in that sub-directory. You can follow my progress and learnings in the <a href=\"https:\/\/github.com\/e8johan\/adventofcode2020\/\">git repository<\/a>.<\/p>\n\n\n\n<p>The lessons this far includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>When using <code>readline<\/code> to read lines, the line-break is included, so <code>len(text)<\/code> will be one character more than expected. Strip your strings!<\/li><li>When doing number of <code>if<\/code> &#8211; <code>elif<\/code> &#8211; <code>elif<\/code> &#8211; <code>elif<\/code>, make sure to include an <code>else<\/code>, even though you know that all cases are covered. I run <code>assert False<\/code> in the else clause.<\/li><\/ul>\n\n\n\n<p>As you can see, these are on the level of small snippets of wisdom right now. I&#8217;m sure it will be more interesting as the problems become more complex.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I decided to do Advent of Code this year too. I usually get stuck part of the way, but I still think that it is a fun exercise. This year the plan is to use python and pytest the whole way through. Every day that i learn something that I want to remember, I &hellip; <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2020\/12\/advent-of-code-and-learning\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Advent of Code and Learning<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1247","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/1247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/comments?post=1247"}],"version-history":[{"count":1,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/1247\/revisions"}],"predecessor-version":[{"id":1251,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/1247\/revisions\/1251"}],"wp:attachment":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/media?parent=1247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/categories?post=1247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/tags?post=1247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}