Skip to content

Advent of Code 2020: "Handy Haversacks" - Day 7

They really trust you a lot ... Now all flights are delayed, that's quite usual in advent times. Except it's 2020 and no one is traveling anyway. But they also impose more regulations, and now bags need to have colours, and bags need to go into other bags. And someone has to figure it out. That's right, it's you! I hope the stopover is long enough to at least grab some ice cream!

Task 1: There is a huge list of rules which colores bag can hold how many other colored bags. You have a "shiny golden" bag, but apparently you are not allowed to carry it around, it has to go into another bag. Find out which ones are allowed, and how many of them. Oh, and bags can go into bags, which means: recursion.

Task 2: As usual someone made a mistake. You are, after all, allowed to carry your "shiny golden" bag, but now you also have to have other bags in it. Calculate the possibilities, based on the rules. Yes, recursion again, and tree climbing.

And if your head is swirling: so is mine. Why on North Pole Earth does anyone even remotely care about your shiny golden bag?

 

Continue reading "Advent of Code 2020: "Handy Haversacks" - Day 7"
  • Twitter
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Advent of Code 2020: "Handy Haversacks" - Day 7
  • Bloglines Advent of Code 2020: "Handy Haversacks" - Day 7
  • Technorati Advent of Code 2020: "Handy Haversacks" - Day 7
  • Fark this: Advent of Code 2020: "Handy Haversacks" - Day 7
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at YahooMyWeb
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at Furl.net
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at reddit.com
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at blinklist.com
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at Spurl.net
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at Simpy.com
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 at blogmarks
  • Bookmark Advent of Code 2020: "Handy Haversacks" - Day 7 with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Advent of Code 2020: "Custom Customs" - Day 6

The flight is approaching a regional airport, but you still have to fill out a customs form. Since you are good with hacking things together, you walk around the plane and gather all the answers from all groups on the plane. There are 26 yes-or-no questions, marked from a to z.

Task 1: Count how many questions are answeres "yes" in each group. Multiple "yes" answers for the same question do not count. The data is provided as blocks, kind of like two days before from the passport scanners. I can re-use some of the code - which will turn out to be a major headache!

Task 2: Of course someone wrote the wrong instructions down! It's up to you to fix the mess now. You have to find out how many groups have the same question answered by anyone in the group.

 

Continue reading "Advent of Code 2020: "Custom Customs" - Day 6"
  • Twitter
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Advent of Code 2020: "Custom Customs" - Day 6
  • Bloglines Advent of Code 2020: "Custom Customs" - Day 6
  • Technorati Advent of Code 2020: "Custom Customs" - Day 6
  • Fark this: Advent of Code 2020: "Custom Customs" - Day 6
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at YahooMyWeb
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at Furl.net
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at reddit.com
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at blinklist.com
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at Spurl.net
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at Simpy.com
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 at blogmarks
  • Bookmark Advent of Code 2020: "Custom Customs" - Day 6 with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Advent of Code 2020: "Binary Boarding" - Day 5

Pretty amazing the tasks they ask you to do "on the fly": Yesterday we fixed the passport scanner, today you have to write a piece of code which scans all the boarding passes in your environment (no one said they all carry them in the hand, and show it to you), and while waiting in the gangway you also have to identify your designated seat. Because, you know, you are such a good hacker you lost your boarding pass on the way from the gate to the plane ;-)

Task 1: Scan all the boarding passes with your phone camera, extract the code, and apply binary pattern matching to identify which seats exist. The airline has a pretty complex scheme going on, which depends on binary space partitioning. Find the highest seat number on the plane.

Task 2: Use the scanned data and find your seat. Seat belts sign is already on and you are still hacking in the gangway, hurry up! The only information you have: your seat exists, it's not the first and last one, and the seats next to yours (-1, +1) exist.

 

Continue reading "Advent of Code 2020: "Binary Boarding" - Day 5"
  • Twitter
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Advent of Code 2020: "Binary Boarding" - Day 5
  • Bloglines Advent of Code 2020: "Binary Boarding" - Day 5
  • Technorati Advent of Code 2020: "Binary Boarding" - Day 5
  • Fark this: Advent of Code 2020: "Binary Boarding" - Day 5
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at YahooMyWeb
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at Furl.net
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at reddit.com
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at blinklist.com
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at Spurl.net
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at Simpy.com
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 at blogmarks
  • Bookmark Advent of Code 2020: "Binary Boarding" - Day 5 with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Advent of Code 2020: "Passport Processing" - Day 4

The challenge for day 4 is more suited for databases. The input is fuzzy, but with a CTE or two I should be able to clean it up. Solved the first part already with the kid earlier, but we decided to skip part two: mainly because it involved more complex string operations (best suited for regex operations), which is something the kid hasn't learned yet.

Task 1: The airport is busy, and the passport scanners do not function correctly. Wondering why every airport seems to be the same mess, but oh well. Anyway, being someone who can do some IT support they ask you to basically hack this thing on the fly and implement passport verification. If that would be possible on a real-world airport ... In addition to all the IT problems there, some people arrive with an ID which was issued by some "North Pole" organization which is not an official government body. But because everyone is waiting in line the people in charge decide to accept this ID as well. Only problem: this ID does not have a "Country ID" code. Your task, if you accept it: check the input data and if only the cid (Country ID) is missing, then accept this non-passport as valid document.

Task 2: Lines are getting longer and longer, and there are still problems with some passports. Your task is to apply additional validation on the fuzzy data which comes from the scanners. The task does not say what happens to people with invalid ID documents, but one can only assume that they cannot board the plane.

 

Continue reading "Advent of Code 2020: "Passport Processing" - Day 4"
  • Twitter
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Advent of Code 2020: "Passport Processing" - Day 4
  • Bloglines Advent of Code 2020: "Passport Processing" - Day 4
  • Technorati Advent of Code 2020: "Passport Processing" - Day 4
  • Fark this: Advent of Code 2020: "Passport Processing" - Day 4
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at YahooMyWeb
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at Furl.net
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at reddit.com
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at blinklist.com
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at Spurl.net
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at Simpy.com
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 at blogmarks
  • Bookmark Advent of Code 2020: "Passport Processing" - Day 4 with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Advent of Code 2020: "Toboggan Trajectory" - Day 3

Have to admit, on first glance this challenge looks a bit complicated. It's well suited for languages which can do string manipulations, but it's not well suited for PostgreSQL. Earlier today I already looked at this problem together with the kid, in Python. Therefore I already knew that I have to jump multiple rows as well. To sum it up: adjust x, including overruns, jump multiple rows in y direction, count trees along the way. All in a single SQL query.

Decided to do the map search in a pl/pgSQL instead, and write a function for it.

Task 1: you get a map of "." and "#", where the "#" are trees. You get instructions to move a certain number of steps into x and y direction, and see if there is a tree. Then repeat until the end of the map. A detail problem is that the number of fields in x direction is smaller than the y direction. There are no clear instructions how to handle this, but the correct solution is to just start at the leftmost position again.

Task 2: Repeat the task from task 1, but 5 times with 5 different instructions for x and y movement. The resulting numbers are to be multiplied.

Continue reading "Advent of Code 2020: "Toboggan Trajectory" - Day 3"
  • Twitter
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Advent of Code 2020: "Toboggan Trajectory" - Day 3
  • Bloglines Advent of Code 2020: "Toboggan Trajectory" - Day 3
  • Technorati Advent of Code 2020: "Toboggan Trajectory" - Day 3
  • Fark this: Advent of Code 2020: "Toboggan Trajectory" - Day 3
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at YahooMyWeb
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at Furl.net
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at reddit.com
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at blinklist.com
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at Spurl.net
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at Simpy.com
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 at blogmarks
  • Bookmark Advent of Code 2020: "Toboggan Trajectory" - Day 3 with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Advent of Code 2020: "Password Philosophy" - Day 2

Day 2, another challenge: fix a broken password database. In order to do that, the passwords which violate the policy must be identified.

Task 1: I get a string, consisting of 2 numbers, a letter, and a password string. Check how many passwords have count(letter) which is between number 1 and number 2.

Task 2: The numbers are positions in the password string (beginning by 1, not 0). Exactly one of the two letters in the string must match the letter.

 

Continue reading "Advent of Code 2020: "Password Philosophy" - Day 2"
  • Twitter
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Advent of Code 2020: "Password Philosophy" - Day 2
  • Bloglines Advent of Code 2020: "Password Philosophy" - Day 2
  • Technorati Advent of Code 2020: "Password Philosophy" - Day 2
  • Fark this: Advent of Code 2020: "Password Philosophy" - Day 2
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at YahooMyWeb
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at Furl.net
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at reddit.com
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at blinklist.com
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at Spurl.net
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at Simpy.com
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 at blogmarks
  • Bookmark Advent of Code 2020: "Password Philosophy" - Day 2 with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Advent of Code 2020: "Report Repair" - Day 1

Started "Advent of Code" with the kid, the kid is polishing the Python (and English) skills. I thought I better do this in SQL.

The Task 1 for "Day 1" is: you get 200 numbers from the accounting department, find the two which in sum are 2020. This two numbers multiplied is the result of the task.

Task 2 is like task 1, except it's using three numbers. All three in sum will be 2020, and then multiply these three and that is the result.

 

Continue reading "Advent of Code 2020: "Report Repair" - Day 1"
  • Twitter
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Advent of Code 2020: "Report Repair" - Day 1
  • Bloglines Advent of Code 2020: "Report Repair" - Day 1
  • Technorati Advent of Code 2020: "Report Repair" - Day 1
  • Fark this: Advent of Code 2020: "Report Repair" - Day 1
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at YahooMyWeb
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at Furl.net
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at reddit.com
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at blinklist.com
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at Spurl.net
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at Simpy.com
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 at blogmarks
  • Bookmark Advent of Code 2020: "Report Repair" - Day 1 with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca