Advent of Code 2022 Day 2

Challenge – Part 1 https://adventofcode.com/2022/day/2 Example For example, suppose you were given the following strategy guide: A Y B X C Z This strategy guide predicts and recommends the following: In the first round, your opponent will choose Rock (A), and you should choose Paper (Y). This ends in a win for you with a…

How to deal with date and time in SQLite

Motivation When dealing with databases you will need the ability to store certain dates and/or timestamps in your tables. Let’s find out how you can do that in an SQLite database. SQL table creation SQLite has the data type TIMESTAMP for storing date-times CREATE TABLE social_media ( social_media_id INTEGER, insertion_date TIMESTAMP, yt_subs INTEGER fb_pg INTEGER…

How to use defaultdict

Motivation When learning a specific language it is essential that you also learn the built-in functionality which gives you leverage. In Python there are often so called pythonic ways to solve problems like lambdas, filter function or enumerate. Tools that save you time when addressing real world problems. Use case Sometimes you want to do…

How to use the configparser module

Motivation Sometimes you need a configuration for your project to adapt to different environments. The easiest way is to alter some variables / constants in your program code. But Hold your horses. This isn’t always a good idea. What if you package your code into an executable with e.g. PyInstaller? Maybe the user of your…