View on GitHub

advent-of-code-2024

Readable Advent of Code 2024 algorithms and solutions in C language

Day 7: Bridge Repair

Let $X\subseteq\mathbb{Z}$. Let $L$ be a set of tuples where for all $(x,\ell)\in L$, we have $x\in X$, and $\ell$ is a list where for all $e\in\ell$ we have $e\in X$. Let $n^\ast=\max_{(x,\ell)\in L}(\mathrm{len}(\ell))$.

Part A

Algorithm 1:

Algorithm 2 with $x,y\in\mathbb{Z}$ and list $\ell=(s_0,\dots,s_{n-1})$ as arguments:

Time complexity: $O(\lvert L\rvert\cdot 2^{n^\ast})$.

Space complexity: $O(n^\ast)$.

Part B

Algorithm 3:

Algorithm 4 with $x,y\in\mathbb{Z}$ and list $\ell=(s_0,\dots,s_{n-1})$ as arguments:

Time complexity: $O(\lvert L\rvert\cdot 3^{n^\ast})$.

Space complexity: $O(n^\ast)$.