8th December solution - Advent of Code 2020 - swift

As part of Advent of Code (adventofcode.com) each day there are two programming tasks to be solved. All solutions are listed here.

I am writing the solutions in Swift with the Playground environment in xCode.

Tasks - 8th December 2020

Given is a list of instructions.

  1. Follow instructions until a instruction is about to be run a second time and print result.

  2. Change one instruction to be able to run until the last instruction.

For a more detailed description of the tasks check this out.

The lines variable is an array of strings containing a set of characters of each member given by Advent of Code, which is individual for each user.

Here is the solution:

Overview of all solutions of 2020:

Advent of Code 2020 Solutions Overview

7th December solution - Advent of Code 2020 - swift

As part of Advent of Code (adventofcode.com) each day there are two programming tasks to be solved. All solutions are listed here.

I am writing the solutions in Swift with the Playground environment in xCode.

Tasks - 7th December 2020

Given is a list of bag, noting which and how many bags of that type can be contained in that bag.

  1. Count the number of bags which can hold a shiny gold bag.

  2. Count the number of bags one shiny gold bag holds.

For a more detailed description of the tasks check this out.

The lines variable is an array of strings containing a set of characters of each member given by Advent of Code, which is individual for each user.

Here is the solution:

Overview of all solutions of 2020:

Advent of Code 2020 Solutions Overview

6th December solution - Advent of Code 2020 - swift

As part of Advent of Code (adventofcode.com) each day there are two programming tasks to be solved. All solutions are listed here.

I am writing the solutions in Swift with the Playground environment in xCode.

Tasks - 6th December 2020

  1. Find the number of unique characters for each group of characters and sum up the count for all groups.

  2. Find the number of shared characters all members of a group of characters share and sum up the count for all groups.

For a more detailed description of the tasks check this out.

The lines variable is an array of strings containing a set of characters of each member given by Advent of Code, which is individual for each user. Each group of multiple members are seperated by a empty line.

Because these two solutions only differ in one line, I made function solving the puzzels, where I provide a boolean, indicating whether the first or the second task is to solved. Here is the solution:

Overview of all solutions of 2020:

Advent of Code 2020 Solutions Overview