[Python/2015] Move solutions into .py files
This commit is contained in:
parent
8c2be5fb77
commit
94dd3ae399
52 changed files with 996 additions and 3314 deletions
|
@ -1,109 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 01"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 1\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"138"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"x = 0\n",
|
||||
"cum = [(x := x + [-1,1][c==\"(\"]) for c in puzzle]\n",
|
||||
"cum[-1]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1771"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"cum.index(-1) + 1"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
9
Python/2015/01.py
Normal file
9
Python/2015/01.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 1)
|
||||
|
||||
x = 0
|
||||
cum = [(x := x + [-1, 1][c == "("]) for c in input]
|
||||
|
||||
print(cum[-1])
|
||||
print(cum.index(-1) + 1)
|
|
@ -1,114 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 02"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 2\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1586300"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"boxes = [sorted(map(int, line.split(\"x\"))) for line in puzzle.splitlines()]\n",
|
||||
"total = 0\n",
|
||||
"for a, b, c in boxes:\n",
|
||||
" total += 2*(a*b+a*c+b*c) + a*b\n",
|
||||
"total"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"3737498"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"total = 0\n",
|
||||
"for a, b, c in boxes:\n",
|
||||
" total += 2*(a+b) + a*b*c\n",
|
||||
"total"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
15
Python/2015/02.py
Normal file
15
Python/2015/02.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 2)
|
||||
|
||||
boxes = [sorted(map(int, line.split("x"))) for line in input.splitlines()]
|
||||
|
||||
total = 0
|
||||
for a, b, c in boxes:
|
||||
total += 2 * (a * b + a * c + b * c) + a * b
|
||||
print(total)
|
||||
|
||||
total = 0
|
||||
for a, b, c in boxes:
|
||||
total += 2 * (a + b) + a * b * c
|
||||
print(total)
|
|
@ -1,117 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 03"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 3\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2572"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def get_houses(instructions):\n",
|
||||
" houses = [(x:=0, y:=0)]\n",
|
||||
" for c in instructions:\n",
|
||||
" x += c==\">\"\n",
|
||||
" x -= c==\"<\"\n",
|
||||
" y += c==\"v\"\n",
|
||||
" y -= c==\"^\"\n",
|
||||
" houses.append((x, y))\n",
|
||||
" return houses\n",
|
||||
"\n",
|
||||
"len(set(get_houses(puzzle)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2631"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(set(get_houses(puzzle[::2])) | set(get_houses(puzzle[1::2])))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
18
Python/2015/03.py
Normal file
18
Python/2015/03.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 3)
|
||||
|
||||
|
||||
def get_houses(instructions):
|
||||
houses = [(x := 0, y := 0)]
|
||||
for c in instructions:
|
||||
x += c == ">"
|
||||
x -= c == "<"
|
||||
y += c == "v"
|
||||
y -= c == "^"
|
||||
houses.append((x, y))
|
||||
return houses
|
||||
|
||||
|
||||
print(len(set(get_houses(input))))
|
||||
print(len(set(get_houses(input[::2])) | set(get_houses(input[1::2]))))
|
|
@ -1,118 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 04"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 4\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"117946"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import hashlib\n",
|
||||
"\n",
|
||||
"def check(inp, cnt):\n",
|
||||
" return hashlib.md5(inp.encode()).hexdigest().startswith(\"0\" * cnt)\n",
|
||||
"\n",
|
||||
"def mine(cnt):\n",
|
||||
" i = 1\n",
|
||||
" while not check(f\"{puzzle}{i}\", cnt):\n",
|
||||
" i += 1\n",
|
||||
" return i\n",
|
||||
"\n",
|
||||
"mine(5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"3938038"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"mine(6)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
18
Python/2015/04.py
Normal file
18
Python/2015/04.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 4)
|
||||
|
||||
|
||||
def check(inp, cnt):
|
||||
return hashlib.md5(inp.encode()).hexdigest().startswith("0" * cnt)
|
||||
|
||||
|
||||
def mine(cnt):
|
||||
i = 1
|
||||
while not check(f"{input.strip()}{i}", cnt):
|
||||
i += 1
|
||||
return i
|
||||
|
||||
|
||||
print(mine(5))
|
||||
print(mine(6))
|
|
@ -1,115 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 05"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 5\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"238"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import re\n",
|
||||
"\n",
|
||||
"def is_nice(x):\n",
|
||||
" return bool(re.match(r\"^(?=(.*[aeiou]){3,})(?=.*(?P<x>.)(?P=x)).*$\", x)) and not any(e in x for e in [\"ab\", \"cd\", \"pq\", \"xy\"])\n",
|
||||
"\n",
|
||||
"sum(map(is_nice, puzzle.splitlines()))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"69"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def is_nice(x):\n",
|
||||
" return bool(re.match(r\"^(?=.*(?P<a>..).*(?P=a))(?=.*(?P<b>.).(?P=b)).*$\", x))\n",
|
||||
"\n",
|
||||
"sum(map(is_nice, puzzle.splitlines()))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
19
Python/2015/05.py
Normal file
19
Python/2015/05.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 5)
|
||||
|
||||
|
||||
def is_nice1(x):
|
||||
return bool(re.match(r"^(?=(.*[aeiou]){3,})(?=.*(?P<x>.)(?P=x)).*$", x)) and not any(
|
||||
e in x for e in ["ab", "cd", "pq", "xy"]
|
||||
)
|
||||
|
||||
|
||||
print(sum(map(is_nice1, input.splitlines())))
|
||||
|
||||
|
||||
def is_nice2(x):
|
||||
return bool(re.match(r"^(?=.*(?P<a>..).*(?P=a))(?=.*(?P<b>.).(?P=b)).*$", x))
|
||||
|
||||
|
||||
print(sum(map(is_nice2, input.splitlines())))
|
|
@ -1,126 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 06"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 6\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"377891"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import re\n",
|
||||
"\n",
|
||||
"def parse_instructions(instructions):\n",
|
||||
" out = []\n",
|
||||
" for line in instructions:\n",
|
||||
" inst, *coords = re.match(r\"^([a-z ]+) (\\d+),(\\d+) through (\\d+),(\\d+)$\", line).groups()\n",
|
||||
" out.append(([\"turn off\", \"turn on\", \"toggle\"].index(inst), *map(int, coords)))\n",
|
||||
" return out\n",
|
||||
"\n",
|
||||
"lights = [[0 for _ in range(1000)] for _ in range(1000)]\n",
|
||||
"for inst, x1, y1, x2, y2 in parse_instructions(puzzle.splitlines()):\n",
|
||||
" for y in range(y1, y2+1):\n",
|
||||
" for x in range(x1, x2+1):\n",
|
||||
" lights[y][x] = 1 - lights[y][x] if inst == 2 else inst\n",
|
||||
"sum(map(sum, lights))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"14110788"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"lights = [[0 for _ in range(1000)] for _ in range(1000)]\n",
|
||||
"for inst, x1, y1, x2, y2 in parse_instructions(puzzle.splitlines()):\n",
|
||||
" for y in range(y1, y2+1):\n",
|
||||
" for x in range(x1, x2+1):\n",
|
||||
" lights[y][x] = max(0, lights[y][x] + (inst or -1))\n",
|
||||
"sum(map(sum, lights))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
30
Python/2015/06.py
Normal file
30
Python/2015/06.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 6)
|
||||
|
||||
|
||||
def parse_instructions(instructions):
|
||||
out = []
|
||||
|
||||
for line in instructions:
|
||||
inst, *coords = re.match(r"^([a-z ]+) (\d+),(\d+) through (\d+),(\d+)$", line).groups()
|
||||
|
||||
out.append((["turn off", "turn on", "toggle"].index(inst), *map(int, coords)))
|
||||
|
||||
return out
|
||||
|
||||
|
||||
lights = [[0 for _ in range(1000)] for _ in range(1000)]
|
||||
for inst, x1, y1, x2, y2 in parse_instructions(input.splitlines()):
|
||||
for y in range(y1, y2 + 1):
|
||||
for x in range(x1, x2 + 1):
|
||||
lights[y][x] = 1 - lights[y][x] if inst == 2 else inst
|
||||
print(sum(map(sum, lights)))
|
||||
|
||||
|
||||
lights = [[0 for _ in range(1000)] for _ in range(1000)]
|
||||
for inst, x1, y1, x2, y2 in parse_instructions(input.splitlines()):
|
||||
for y in range(y1, y2 + 1):
|
||||
for x in range(x1, x2 + 1):
|
||||
lights[y][x] = max(0, lights[y][x] + (inst or -1))
|
||||
print(sum(map(sum, lights)))
|
|
@ -1,139 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 07"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 7\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 37,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"956"
|
||||
]
|
||||
},
|
||||
"execution_count": 37,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"MOD = 1<<16\n",
|
||||
"\n",
|
||||
"funcs = {dest: args for *args, _, dest in map(str.split, puzzle.splitlines())}\n",
|
||||
"\n",
|
||||
"dp = {}\n",
|
||||
"\n",
|
||||
"def solve(key):\n",
|
||||
" if key not in dp:\n",
|
||||
" if key.isnumeric():\n",
|
||||
" val = int(key)\n",
|
||||
" else:\n",
|
||||
" args = funcs[key]\n",
|
||||
" if len(args) == 1:\n",
|
||||
" val = solve(args[0])\n",
|
||||
" elif len(args) == 2:\n",
|
||||
" if args[0] == \"NOT\":\n",
|
||||
" val = ~solve(args[1]) % MOD\n",
|
||||
" elif len(args) == 3:\n",
|
||||
" if args[1] == \"OR\":\n",
|
||||
" val = solve(args[0]) | solve(args[2])\n",
|
||||
" elif args[1] == \"AND\":\n",
|
||||
" val = solve(args[0]) & solve(args[2])\n",
|
||||
" elif args[1] == \"LSHIFT\":\n",
|
||||
" val = solve(args[0]) << solve(args[2])\n",
|
||||
" elif args[1] == \"RSHIFT\":\n",
|
||||
" val = solve(args[0]) >> solve(args[2])\n",
|
||||
" dp[key] = val % MOD\n",
|
||||
" \n",
|
||||
" return dp[key]\n",
|
||||
"\n",
|
||||
"solve(\"a\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 38,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"40149"
|
||||
]
|
||||
},
|
||||
"execution_count": 38,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"dp.clear()\n",
|
||||
"dp = {\"b\": solve(\"a\")}\n",
|
||||
"solve(\"a\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
50
Python/2015/07.py
Normal file
50
Python/2015/07.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 7)
|
||||
|
||||
MOD = 1 << 16
|
||||
|
||||
|
||||
funcs = {dest: args for *args, _, dest in map(str.split, input.splitlines())}
|
||||
|
||||
dp = {}
|
||||
|
||||
|
||||
def solve(key):
|
||||
if key not in dp:
|
||||
if key.isnumeric():
|
||||
val = int(key)
|
||||
|
||||
else:
|
||||
args = funcs[key]
|
||||
|
||||
if len(args) == 1:
|
||||
val = solve(args[0])
|
||||
|
||||
elif len(args) == 2:
|
||||
if args[0] == "NOT":
|
||||
val = ~solve(args[1]) % MOD
|
||||
|
||||
elif len(args) == 3:
|
||||
if args[1] == "OR":
|
||||
val = solve(args[0]) | solve(args[2])
|
||||
|
||||
elif args[1] == "AND":
|
||||
val = solve(args[0]) & solve(args[2])
|
||||
|
||||
elif args[1] == "LSHIFT":
|
||||
val = solve(args[0]) << solve(args[2])
|
||||
|
||||
elif args[1] == "RSHIFT":
|
||||
val = solve(args[0]) >> solve(args[2])
|
||||
|
||||
dp[key] = val % MOD
|
||||
|
||||
return dp[key]
|
||||
|
||||
|
||||
print(solve("a"))
|
||||
|
||||
dp.clear()
|
||||
dp = {"b": solve("a")}
|
||||
print(solve("a"))
|
|
@ -1,107 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 08"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 8\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1342"
|
||||
]
|
||||
},
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"sum(len(line) - len(eval(line)) for line in puzzle.splitlines())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2074"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"sum(len(repr(line))+line.count('\"') - len(line) for line in puzzle.splitlines())"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
6
Python/2015/08.py
Normal file
6
Python/2015/08.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 8)
|
||||
|
||||
print(sum(len(line) - len(eval(line)) for line in input.splitlines()))
|
||||
print(sum(len(repr(line)) + line.count('"') - len(line) for line in input.splitlines()))
|
|
@ -1,114 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 09"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 9\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"207"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import itertools\n",
|
||||
"\n",
|
||||
"graph = {}\n",
|
||||
"for src, _, dst, _, dist in map(str.split, puzzle.splitlines()):\n",
|
||||
" graph.setdefault(src, {})[dst] = int(dist)\n",
|
||||
" graph.setdefault(dst, {})[src] = int(dist)\n",
|
||||
"\n",
|
||||
"min(sum(graph[a][b] for a, b in zip(locs, locs[1:])) for locs in itertools.permutations(graph))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"804"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"max(sum(graph[a][b] for a, b in zip(locs, locs[1:])) for locs in itertools.permutations(graph))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
13
Python/2015/09.py
Normal file
13
Python/2015/09.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 9)
|
||||
|
||||
|
||||
graph = {}
|
||||
for src, _, dst, _, dist in map(str.split, input.splitlines()):
|
||||
graph.setdefault(src, {})[dst] = int(dist)
|
||||
graph.setdefault(dst, {})[src] = int(dist)
|
||||
|
||||
|
||||
print(min(sum(graph[a][b] for a, b in zip(locs, locs[1:])) for locs in itertools.permutations(graph)))
|
||||
print(max(sum(graph[a][b] for a, b in zip(locs, locs[1:])) for locs in itertools.permutations(graph)))
|
|
@ -1,125 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 10"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 10\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"329356"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def las(inp):\n",
|
||||
" out = \"\"\n",
|
||||
" i = 0\n",
|
||||
" while i < len(inp):\n",
|
||||
" c = inp[i]\n",
|
||||
" j = 1\n",
|
||||
" while i+j < len(inp) and inp[i+j] == c:\n",
|
||||
" j += 1\n",
|
||||
" out += f\"{j}{c}\"\n",
|
||||
" i += j\n",
|
||||
" return out\n",
|
||||
"\n",
|
||||
"x = puzzle\n",
|
||||
"for _ in range(40):\n",
|
||||
" x = las(x)\n",
|
||||
"len(x)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4666278"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"x = puzzle\n",
|
||||
"for _ in range(50):\n",
|
||||
" x = las(x)\n",
|
||||
"len(x)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
27
Python/2015/10.py
Normal file
27
Python/2015/10.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 10)
|
||||
|
||||
|
||||
def las(inp):
|
||||
out = ""
|
||||
i = 0
|
||||
while i < len(inp):
|
||||
c = inp[i]
|
||||
j = 1
|
||||
while i + j < len(inp) and inp[i + j] == c:
|
||||
j += 1
|
||||
out += f"{j}{c}"
|
||||
i += j
|
||||
return out
|
||||
|
||||
|
||||
x = input.strip()
|
||||
for _ in range(40):
|
||||
x = las(x)
|
||||
print(len(x))
|
||||
|
||||
x = input.strip()
|
||||
for _ in range(50):
|
||||
x = las(x)
|
||||
print(len(x))
|
|
@ -1,127 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 11"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 11\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'cqjxxyzz'"
|
||||
]
|
||||
},
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def inc(x):\n",
|
||||
" x = [ord(c)-0x61 for c in x]\n",
|
||||
" for i in range(len(x))[::-1]:\n",
|
||||
" x[i] += 1\n",
|
||||
" while chr(0x61+x[i]) in \"iol\":\n",
|
||||
" x[i] += 1\n",
|
||||
" if x[i] < 26:\n",
|
||||
" break\n",
|
||||
" x[i] = 0\n",
|
||||
" return \"\".join(chr(c+0x61) for c in x)\n",
|
||||
"\n",
|
||||
"def check(x):\n",
|
||||
" return all(c not in x for c in \"iol\") and any((chr(i)+chr(i+1)+chr(i+2)) in x for i in range(0x61,0x61+24)) and sum(chr(0x61+i)*2 in x for i in range(26))>=2\n",
|
||||
"\n",
|
||||
"def nxt(x):\n",
|
||||
" x = inc(x)\n",
|
||||
" while not check(x):\n",
|
||||
" x = inc(x)\n",
|
||||
" return x\n",
|
||||
"\n",
|
||||
"nxt(puzzle)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'cqkaabcc'"
|
||||
]
|
||||
},
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"nxt(nxt(puzzle))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
34
Python/2015/11.py
Normal file
34
Python/2015/11.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 11)
|
||||
|
||||
|
||||
def inc(x):
|
||||
x = [ord(c) - 0x61 for c in x]
|
||||
for i in range(len(x))[::-1]:
|
||||
x[i] += 1
|
||||
while chr(0x61 + x[i]) in "iol":
|
||||
x[i] += 1
|
||||
if x[i] < 26:
|
||||
break
|
||||
x[i] = 0
|
||||
return "".join(chr(c + 0x61) for c in x)
|
||||
|
||||
|
||||
def check(x):
|
||||
return (
|
||||
all(c not in x for c in "iol")
|
||||
and any((chr(i) + chr(i + 1) + chr(i + 2)) in x for i in range(0x61, 0x61 + 24))
|
||||
and sum(chr(0x61 + i) * 2 in x for i in range(26)) >= 2
|
||||
)
|
||||
|
||||
|
||||
def nxt(x):
|
||||
x = inc(x)
|
||||
while not check(x):
|
||||
x = inc(x)
|
||||
return x
|
||||
|
||||
|
||||
print(a := nxt(input.strip()))
|
||||
print(nxt(a))
|
|
@ -1,131 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 12"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 12\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"111754"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"data = json.loads(puzzle)\n",
|
||||
"\n",
|
||||
"def count(obj):\n",
|
||||
" if isinstance(obj, dict):\n",
|
||||
" return sum(map(count, obj.values()))\n",
|
||||
" elif isinstance(obj, list):\n",
|
||||
" return sum(map(count, obj))\n",
|
||||
" elif isinstance(obj, int):\n",
|
||||
" return obj\n",
|
||||
" return 0\n",
|
||||
"\n",
|
||||
"count(data)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"65402"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def count(obj):\n",
|
||||
" if isinstance(obj, dict):\n",
|
||||
" if \"red\" in obj.values():\n",
|
||||
" return 0\n",
|
||||
" return sum(map(count, obj.values()))\n",
|
||||
" elif isinstance(obj, list):\n",
|
||||
" return sum(map(count, obj))\n",
|
||||
" elif isinstance(obj, int):\n",
|
||||
" return obj\n",
|
||||
" return 0\n",
|
||||
"\n",
|
||||
"count(data)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
40
Python/2015/12.py
Normal file
40
Python/2015/12.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 12)
|
||||
|
||||
data = json.loads(input)
|
||||
|
||||
|
||||
def count1(obj):
|
||||
if isinstance(obj, dict):
|
||||
return sum(map(count1, obj.values()))
|
||||
|
||||
elif isinstance(obj, list):
|
||||
return sum(map(count1, obj))
|
||||
|
||||
elif isinstance(obj, int):
|
||||
return obj
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
print(count1(data))
|
||||
|
||||
|
||||
def count2(obj):
|
||||
if isinstance(obj, dict):
|
||||
if "red" in obj.values():
|
||||
return 0
|
||||
|
||||
return sum(map(count2, obj.values()))
|
||||
|
||||
elif isinstance(obj, list):
|
||||
return sum(map(count2, obj))
|
||||
|
||||
elif isinstance(obj, int):
|
||||
return obj
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
print(count2(data))
|
|
@ -1,121 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 13"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 13\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"733"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import itertools\n",
|
||||
"\n",
|
||||
"hp = {}\n",
|
||||
"\n",
|
||||
"for a, _, m, c, *_, b in map(str.split, puzzle.splitlines()):\n",
|
||||
" b = b[:-1]\n",
|
||||
" c = int(c)\n",
|
||||
" if m == \"lose\":\n",
|
||||
" c *= -1\n",
|
||||
" hp.setdefault(b, {})[a] = hp[a][b] = hp.setdefault(a, {}).get(b, 0) + c\n",
|
||||
"\n",
|
||||
"def calc(table):\n",
|
||||
" return sum(hp.get(table[i],{}).get(table[(i+1)%len(table)],0) for i in range(len(table)))\n",
|
||||
"\n",
|
||||
"max(map(calc, itertools.permutations(hp)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"725"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"max(map(calc, itertools.permutations([*hp,\"_\"])))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
24
Python/2015/13.py
Normal file
24
Python/2015/13.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 13)
|
||||
|
||||
hp = {}
|
||||
|
||||
|
||||
for a, _, m, c, *_, b in map(str.split, input.splitlines()):
|
||||
b = b[:-1]
|
||||
|
||||
c = int(c)
|
||||
|
||||
if m == "lose":
|
||||
c *= -1
|
||||
|
||||
hp.setdefault(b, {})[a] = hp[a][b] = hp.setdefault(a, {}).get(b, 0) + c
|
||||
|
||||
|
||||
def calc(table):
|
||||
return sum(hp.get(table[i], {}).get(table[(i + 1) % len(table)], 0) for i in range(len(table)))
|
||||
|
||||
|
||||
print(max(map(calc, itertools.permutations(hp))))
|
||||
print(max(map(calc, itertools.permutations([*hp, "_"]))))
|
|
@ -1,134 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 14"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 14\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2640"
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"T = 2503\n",
|
||||
"out = 0\n",
|
||||
"\n",
|
||||
"for line in map(str.split, puzzle.splitlines()):\n",
|
||||
" v, t, r = map(int, [line[3], line[6], line[-2]])\n",
|
||||
" x = T // (t + r) * t * v\n",
|
||||
" x += min(t, T % (t + r)) * v\n",
|
||||
" out = max(out, x)\n",
|
||||
"out"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 37,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1102"
|
||||
]
|
||||
},
|
||||
"execution_count": 37,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"T = 2503\n",
|
||||
"\n",
|
||||
"reindeers = [tuple(map(int, [line[3], line[6], line[-2]])) for line in map(str.split, puzzle.splitlines())]\n",
|
||||
"states = [0]*len(reindeers)\n",
|
||||
"meters = [0]*len(reindeers)\n",
|
||||
"bonus = [0]*len(reindeers)\n",
|
||||
"\n",
|
||||
"for _ in range(T):\n",
|
||||
" for i, (v, t, r) in enumerate(reindeers):\n",
|
||||
" if states[i] >= 0:\n",
|
||||
" meters[i] += v\n",
|
||||
" states[i] += 1\n",
|
||||
" if states[i] >= t:\n",
|
||||
" states[i] = -r\n",
|
||||
" mx = max(meters)\n",
|
||||
" for i, m in enumerate(meters):\n",
|
||||
" if m == mx:\n",
|
||||
" bonus[i] += 1\n",
|
||||
"\n",
|
||||
"max(bonus)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
37
Python/2015/14.py
Normal file
37
Python/2015/14.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 14)
|
||||
|
||||
T = 2503
|
||||
out = 0
|
||||
|
||||
|
||||
for line in map(str.split, input.splitlines()):
|
||||
v, t, r = map(int, [line[3], line[6], line[-2]])
|
||||
x = T // (t + r) * t * v
|
||||
x += min(t, T % (t + r)) * v
|
||||
out = max(out, x)
|
||||
|
||||
print(out)
|
||||
|
||||
|
||||
T = 2503
|
||||
reindeers = [tuple(map(int, [line[3], line[6], line[-2]])) for line in map(str.split, input.splitlines())]
|
||||
states = [0] * len(reindeers)
|
||||
meters = [0] * len(reindeers)
|
||||
bonus = [0] * len(reindeers)
|
||||
for _ in range(T):
|
||||
for i, (v, t, r) in enumerate(reindeers):
|
||||
if states[i] >= 0:
|
||||
meters[i] += v
|
||||
|
||||
states[i] += 1
|
||||
if states[i] >= t:
|
||||
states[i] = -r
|
||||
|
||||
mx = max(meters)
|
||||
for i, m in enumerate(meters):
|
||||
if m == mx:
|
||||
bonus[i] += 1
|
||||
|
||||
print(max(bonus))
|
|
@ -1,133 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 15"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 15\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"13882464"
|
||||
]
|
||||
},
|
||||
"execution_count": 32,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"TOTAL = 100\n",
|
||||
"\n",
|
||||
"ingredients = [[int(x.strip(\",\")) for x in i[2:-1:2]] for i in map(str.split, puzzle.splitlines())]\n",
|
||||
"\n",
|
||||
"def solve(i, x, prev):\n",
|
||||
" if i == len(ingredients)-1:\n",
|
||||
" out = 1\n",
|
||||
" for p,e in zip(prev,ingredients[-1]):\n",
|
||||
" out *= max(0, p+x*e)\n",
|
||||
" return out\n",
|
||||
" \n",
|
||||
" return max(solve(i + 1, x - j, [a+j*b for a, b in zip(prev, ingredients[i])]) for j in range(x + 1))\n",
|
||||
"\n",
|
||||
"solve(0, TOTAL, [0]*4)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"11171160"
|
||||
]
|
||||
},
|
||||
"execution_count": 33,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"ingredients = [[int(x.strip(\",\")) for x in i[2::2]] for i in map(str.split, puzzle.splitlines())]\n",
|
||||
"\n",
|
||||
"def solve(i, x, prev):\n",
|
||||
" if i == len(ingredients)-1:\n",
|
||||
" if prev[-1]+x*ingredients[-1][-1] != 500:\n",
|
||||
" return 0\n",
|
||||
" out = 1\n",
|
||||
" for p,e in zip(prev[:-1],ingredients[-1][:-1]):\n",
|
||||
" out *= max(0, p+x*e)\n",
|
||||
" return out\n",
|
||||
" \n",
|
||||
" return max(solve(i + 1, x - j, [a+j*b for a, b in zip(prev, ingredients[i])]) for j in range(x + 1))\n",
|
||||
"\n",
|
||||
"solve(0, TOTAL, [0]*5)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
44
Python/2015/15.py
Normal file
44
Python/2015/15.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 15)
|
||||
|
||||
TOTAL = 100
|
||||
|
||||
|
||||
ingredients = [[int(x.strip(",")) for x in i[2:-1:2]] for i in map(str.split, input.splitlines())]
|
||||
|
||||
|
||||
def solve1(i, x, prev):
|
||||
if i == len(ingredients) - 1:
|
||||
out = 1
|
||||
|
||||
for p, e in zip(prev, ingredients[-1]):
|
||||
out *= max(0, p + x * e)
|
||||
|
||||
return out
|
||||
|
||||
return max(solve1(i + 1, x - j, [a + j * b for a, b in zip(prev, ingredients[i])]) for j in range(x + 1))
|
||||
|
||||
|
||||
print(solve1(0, TOTAL, [0] * 4))
|
||||
|
||||
|
||||
ingredients = [[int(x.strip(",")) for x in i[2::2]] for i in map(str.split, input.splitlines())]
|
||||
|
||||
|
||||
def solve2(i, x, prev):
|
||||
if i == len(ingredients) - 1:
|
||||
if prev[-1] + x * ingredients[-1][-1] != 500:
|
||||
return 0
|
||||
|
||||
out = 1
|
||||
|
||||
for p, e in zip(prev[:-1], ingredients[-1][:-1]):
|
||||
out *= max(0, p + x * e)
|
||||
|
||||
return out
|
||||
|
||||
return max(solve2(i + 1, x - j, [a + j * b for a, b in zip(prev, ingredients[i])]) for j in range(x + 1))
|
||||
|
||||
|
||||
print(solve2(0, TOTAL, [0] * 5))
|
|
@ -1,132 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 16"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 16\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"373"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"aunts = [{k:int(v) for k, v in map(str.split, \"\".join(line.split()[2:]).replace(\":\",\" \").split(\",\"))} for line in puzzle.splitlines()]\n",
|
||||
"\n",
|
||||
"sue = {\n",
|
||||
" \"children\": 3,\n",
|
||||
" \"cats\": 7,\n",
|
||||
" \"samoyeds\": 2,\n",
|
||||
" \"pomeranians\": 3,\n",
|
||||
" \"akitas\": 0,\n",
|
||||
" \"vizslas\": 0,\n",
|
||||
" \"goldfish\": 5,\n",
|
||||
" \"trees\": 3,\n",
|
||||
" \"cars\": 2,\n",
|
||||
" \"perfumes\": 1,\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"for i, x in enumerate(aunts):\n",
|
||||
" if all(k not in x or x[k]==v for k, v in sue.items()):\n",
|
||||
" break\n",
|
||||
"i+1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"260"
|
||||
]
|
||||
},
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for i, x in enumerate(aunts):\n",
|
||||
" if not all(k not in x or x[k]>sue[k] for k in [\"cats\",\"trees\"]):\n",
|
||||
" continue\n",
|
||||
" if not all(k not in x or x[k]<sue[k] for k in [\"pomeranians\",\"goldfish\"]):\n",
|
||||
" continue\n",
|
||||
" if all(k not in x or x[k]==v for k, v in sue.items() if k not in [\"cats\",\"trees\",\"pomeranians\",\"goldfish\"]):\n",
|
||||
" break\n",
|
||||
"i+1"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
38
Python/2015/16.py
Normal file
38
Python/2015/16.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 16)
|
||||
|
||||
aunts = [
|
||||
{k: int(v) for k, v in map(str.split, "".join(line.split()[2:]).replace(":", " ").split(","))}
|
||||
for line in input.splitlines()
|
||||
]
|
||||
|
||||
|
||||
sue = {
|
||||
"children": 3,
|
||||
"cats": 7,
|
||||
"samoyeds": 2,
|
||||
"pomeranians": 3,
|
||||
"akitas": 0,
|
||||
"vizslas": 0,
|
||||
"goldfish": 5,
|
||||
"trees": 3,
|
||||
"cars": 2,
|
||||
"perfumes": 1,
|
||||
}
|
||||
|
||||
|
||||
for i, x in enumerate(aunts):
|
||||
if all(k not in x or x[k] == v for k, v in sue.items()):
|
||||
print(i + 1)
|
||||
break
|
||||
|
||||
|
||||
for i, x in enumerate(aunts):
|
||||
if not all(k not in x or x[k] > sue[k] for k in ["cats", "trees"]):
|
||||
continue
|
||||
if not all(k not in x or x[k] < sue[k] for k in ["pomeranians", "goldfish"]):
|
||||
continue
|
||||
if all(k not in x or x[k] == v for k, v in sue.items() if k not in ["cats", "trees", "pomeranians", "goldfish"]):
|
||||
print(i + 1)
|
||||
break
|
|
@ -1,142 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 17"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 17\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1638"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"containers = list(map(int, puzzle.splitlines()))\n",
|
||||
"dp = {}\n",
|
||||
"\n",
|
||||
"def solve(i, x):\n",
|
||||
" if i == len(containers):\n",
|
||||
" return int(x == 0)\n",
|
||||
" \n",
|
||||
" if (i,x) not in dp:\n",
|
||||
" out = solve(i + 1, x)\n",
|
||||
" if containers[i] <= x:\n",
|
||||
" out += solve(i + 1, x - containers[i])\n",
|
||||
" dp[(i, x)] = out\n",
|
||||
" return dp[(i, x)]\n",
|
||||
"\n",
|
||||
"solve(0, 150)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"17"
|
||||
]
|
||||
},
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"containers = list(map(int, puzzle.splitlines()))\n",
|
||||
"dp = {}\n",
|
||||
"\n",
|
||||
"def solve(i, x):\n",
|
||||
" if i == len(containers):\n",
|
||||
" return None if x else (0, 1)\n",
|
||||
" \n",
|
||||
" if (i,x) not in dp:\n",
|
||||
" out = solve(i + 1, x)\n",
|
||||
" if containers[i] <= x:\n",
|
||||
" y = solve(i + 1, x - containers[i])\n",
|
||||
" if y is not None:\n",
|
||||
" l, c = y\n",
|
||||
" l += 1\n",
|
||||
" if out is None or l < out[0]:\n",
|
||||
" out = l, c\n",
|
||||
" elif out is not None and out[0] == l:\n",
|
||||
" out = l, out[1] + c\n",
|
||||
" dp[(i, x)] = out\n",
|
||||
" return dp[(i, x)]\n",
|
||||
"\n",
|
||||
"solve(0, 150)[1]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
58
Python/2015/17.py
Normal file
58
Python/2015/17.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 17)
|
||||
|
||||
containers = list(map(int, input.splitlines()))
|
||||
|
||||
dp = {}
|
||||
|
||||
|
||||
def solve1(i, x):
|
||||
if i == len(containers):
|
||||
return int(x == 0)
|
||||
|
||||
if (i, x) not in dp:
|
||||
out = solve1(i + 1, x)
|
||||
|
||||
if containers[i] <= x:
|
||||
out += solve1(i + 1, x - containers[i])
|
||||
|
||||
dp[(i, x)] = out
|
||||
|
||||
return dp[(i, x)]
|
||||
|
||||
|
||||
print(solve1(0, 150))
|
||||
|
||||
|
||||
containers = list(map(int, input.splitlines()))
|
||||
dp = {}
|
||||
|
||||
|
||||
def solve2(i, x):
|
||||
if i == len(containers):
|
||||
return None if x else (0, 1)
|
||||
|
||||
if (i, x) not in dp:
|
||||
out = solve2(i + 1, x)
|
||||
|
||||
if containers[i] <= x:
|
||||
y = solve2(i + 1, x - containers[i])
|
||||
|
||||
if y is not None:
|
||||
l, c = y
|
||||
|
||||
l += 1
|
||||
|
||||
if out is None or l < out[0]:
|
||||
out = l, c
|
||||
|
||||
elif out is not None and out[0] == l:
|
||||
out = l, out[1] + c
|
||||
|
||||
dp[(i, x)] = out
|
||||
|
||||
return dp[(i, x)]
|
||||
|
||||
|
||||
print(solve2(0, 150)[1])
|
|
@ -1,130 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 18"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 18\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"814"
|
||||
]
|
||||
},
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"gol = puzzle.splitlines()\n",
|
||||
"\n",
|
||||
"for _ in range(100):\n",
|
||||
" gol = [\n",
|
||||
" [\n",
|
||||
" \".#\"[(cnt:=sum(gol[p][q]==\"#\" for r in range(3) for s in range(3) if (r,s)!=(1,1) and 0<=(p:=i-1+r)<len(gol) and 0<=(q:=j-1+s)<len(row))) in (2,3) and x==\"#\" or x==\".\" and cnt==3]\n",
|
||||
" for j, x in enumerate(row)\n",
|
||||
" ]\n",
|
||||
" for i, row in enumerate(gol)\n",
|
||||
" ]\n",
|
||||
"sum(x==\"#\" for row in gol for x in row)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"924"
|
||||
]
|
||||
},
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"gol = list(map(list, puzzle.splitlines()))\n",
|
||||
"gol[0][0] = gol[0][-1] = gol[-1][0] = gol[-1][-1] = \"#\"\n",
|
||||
"\n",
|
||||
"for _ in range(100):\n",
|
||||
" gol = [\n",
|
||||
" [\n",
|
||||
" \".#\"[(cnt:=sum(gol[p][q]==\"#\" for r in range(3) for s in range(3) if (r,s)!=(1,1) and 0<=(p:=i-1+r)<len(gol) and 0<=(q:=j-1+s)<len(row))) in (2,3) and x==\"#\" or x==\".\" and cnt==3]\n",
|
||||
" for j, x in enumerate(row)\n",
|
||||
" ]\n",
|
||||
" for i, row in enumerate(gol)\n",
|
||||
" ]\n",
|
||||
" gol[0][0] = gol[0][-1] = gol[-1][0] = gol[-1][-1] = \"#\"\n",
|
||||
" \n",
|
||||
"sum(x==\"#\" for row in gol for x in row)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
59
Python/2015/18.py
Normal file
59
Python/2015/18.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 18)
|
||||
|
||||
gol = input.splitlines()
|
||||
|
||||
|
||||
for _ in range(100):
|
||||
gol = [
|
||||
[
|
||||
".#"[
|
||||
(
|
||||
cnt := sum(
|
||||
gol[p][q] == "#"
|
||||
for r in range(3)
|
||||
for s in range(3)
|
||||
if (r, s) != (1, 1) and 0 <= (p := i - 1 + r) < len(gol) and 0 <= (q := j - 1 + s) < len(row)
|
||||
)
|
||||
)
|
||||
in (2, 3)
|
||||
and x == "#"
|
||||
or x == "."
|
||||
and cnt == 3
|
||||
]
|
||||
for j, x in enumerate(row)
|
||||
]
|
||||
for i, row in enumerate(gol)
|
||||
]
|
||||
|
||||
print(sum(x == "#" for row in gol for x in row))
|
||||
|
||||
|
||||
gol = list(map(list, input.splitlines()))
|
||||
gol[0][0] = gol[0][-1] = gol[-1][0] = gol[-1][-1] = "#"
|
||||
for _ in range(100):
|
||||
gol = [
|
||||
[
|
||||
".#"[
|
||||
(
|
||||
cnt := sum(
|
||||
gol[p][q] == "#"
|
||||
for r in range(3)
|
||||
for s in range(3)
|
||||
if (r, s) != (1, 1) and 0 <= (p := i - 1 + r) < len(gol) and 0 <= (q := j - 1 + s) < len(row)
|
||||
)
|
||||
)
|
||||
in (2, 3)
|
||||
and x == "#"
|
||||
or x == "."
|
||||
and cnt == 3
|
||||
]
|
||||
for j, x in enumerate(row)
|
||||
]
|
||||
for i, row in enumerate(gol)
|
||||
]
|
||||
gol[0][0] = gol[0][-1] = gol[-1][0] = gol[-1][-1] = "#"
|
||||
|
||||
|
||||
print(sum(x == "#" for row in gol for x in row))
|
|
@ -1,139 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 19"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 19\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"518"
|
||||
]
|
||||
},
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"*replacements, _, mol = puzzle.splitlines()\n",
|
||||
"rep = {}\n",
|
||||
"for k, _, v in map(str.split, replacements):\n",
|
||||
" rep.setdefault(k, []).append(v)\n",
|
||||
"\n",
|
||||
"out = set()\n",
|
||||
"for k, v in rep.items():\n",
|
||||
" for i in range(len(mol)):\n",
|
||||
" if k == mol[i:i+len(k)]:\n",
|
||||
" for e in v:\n",
|
||||
" out.add(mol[:i] + e + mol[i+len(k):])\n",
|
||||
"len(out)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 78,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"200"
|
||||
]
|
||||
},
|
||||
"execution_count": 78,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"*replacements, _, mol = puzzle.splitlines()\n",
|
||||
"rep = {}\n",
|
||||
"for v, _, k in map(str.split, replacements):\n",
|
||||
" rep[k] = v\n",
|
||||
"\n",
|
||||
"def replace(inp):\n",
|
||||
" out = set()\n",
|
||||
" for k, v in rep.items():\n",
|
||||
" for i in range(len(inp)):\n",
|
||||
" if k == inp[i:i+len(k)]:\n",
|
||||
" out.add(inp[:i] + v + inp[i+len(k):])\n",
|
||||
" return out\n",
|
||||
"\n",
|
||||
"def solve(inp):\n",
|
||||
" if inp == \"e\":\n",
|
||||
" return 0\n",
|
||||
" \n",
|
||||
" for x in replace(inp):\n",
|
||||
" if (y := solve(x)) is not None:\n",
|
||||
" return y + 1\n",
|
||||
"\n",
|
||||
"solve(mol)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
43
Python/2015/19.py
Normal file
43
Python/2015/19.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 19)
|
||||
|
||||
*replacements, _, mol = input.splitlines()
|
||||
rep = {}
|
||||
for k, _, v in map(str.split, replacements):
|
||||
rep.setdefault(k, []).append(v)
|
||||
|
||||
out = set()
|
||||
for k, v in rep.items():
|
||||
for i in range(len(mol)):
|
||||
if k == mol[i : i + len(k)]:
|
||||
for e in v:
|
||||
out.add(mol[:i] + e + mol[i + len(k) :])
|
||||
|
||||
print(len(out))
|
||||
|
||||
|
||||
*replacements, _, mol = input.splitlines()
|
||||
rep = {}
|
||||
for v, _, k in map(str.split, replacements):
|
||||
rep[k] = v
|
||||
|
||||
|
||||
def replace(inp):
|
||||
out = set()
|
||||
for k, v in rep.items():
|
||||
for i in range(len(inp)):
|
||||
if k == inp[i : i + len(k)]:
|
||||
out.add(inp[:i] + v + inp[i + len(k) :])
|
||||
return out
|
||||
|
||||
|
||||
def solve(inp):
|
||||
if inp == "e":
|
||||
return 0
|
||||
for x in replace(inp):
|
||||
if (y := solve(x)) is not None:
|
||||
return y + 1
|
||||
|
||||
|
||||
print(solve(mol))
|
|
@ -1,131 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 20"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 20\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"665280"
|
||||
]
|
||||
},
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"target = int(puzzle) // 10\n",
|
||||
"\n",
|
||||
"houses = [0] * target\n",
|
||||
"for i in range(1, target + 1):\n",
|
||||
" k = i-1\n",
|
||||
" while k < target:\n",
|
||||
" houses[k] += i\n",
|
||||
" k += i\n",
|
||||
"for i, x in enumerate(houses):\n",
|
||||
" if x >= target:\n",
|
||||
" break\n",
|
||||
"i+1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"705600"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"target = int(puzzle) // 11\n",
|
||||
"\n",
|
||||
"houses = [0] * target\n",
|
||||
"for i in range(1, target + 1):\n",
|
||||
" k = i-1\n",
|
||||
" c = 0\n",
|
||||
" while k < target and c < 50:\n",
|
||||
" c += 1\n",
|
||||
" houses[k] += i\n",
|
||||
" k += i\n",
|
||||
"for i, x in enumerate(houses):\n",
|
||||
" if x >= target:\n",
|
||||
" break\n",
|
||||
"i+1"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
33
Python/2015/20.py
Normal file
33
Python/2015/20.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 20)
|
||||
|
||||
target = int(input) // 10
|
||||
|
||||
houses = [0] * target
|
||||
for i in range(1, target + 1):
|
||||
k = i - 1
|
||||
while k < target:
|
||||
houses[k] += i
|
||||
k += i
|
||||
|
||||
for i, x in enumerate(houses):
|
||||
if x >= target:
|
||||
print(i + 1)
|
||||
break
|
||||
|
||||
|
||||
target = int(input) // 11
|
||||
houses = [0] * target
|
||||
for i in range(1, target + 1):
|
||||
k = i - 1
|
||||
c = 0
|
||||
while k < target and c < 50:
|
||||
c += 1
|
||||
houses[k] += i
|
||||
k += i
|
||||
|
||||
for i, x in enumerate(houses):
|
||||
if x >= target:
|
||||
print(i + 1)
|
||||
break
|
|
@ -1,169 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 21"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 21\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"111"
|
||||
]
|
||||
},
|
||||
"execution_count": 43,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(*_, boss_hp), (*_, boss_damage), (*_, boss_armor) = map(str.split, puzzle.splitlines())\n",
|
||||
"boss_hp, boss_damage, boss_armor = map(int, [boss_hp, boss_damage, boss_armor])\n",
|
||||
"\n",
|
||||
"player_hp = 100\n",
|
||||
"\n",
|
||||
"NEUTRAL = (0, 0, 0)\n",
|
||||
"shop_weapons = [\n",
|
||||
" (8, 4, 0),\n",
|
||||
" (10, 5, 0),\n",
|
||||
" (25, 6, 0),\n",
|
||||
" (40, 7, 0),\n",
|
||||
" (74, 8, 0),\n",
|
||||
"]\n",
|
||||
"shop_armor = [\n",
|
||||
" NEUTRAL,\n",
|
||||
" (13, 0, 1),\n",
|
||||
" (31, 0, 2),\n",
|
||||
" (53, 0, 3),\n",
|
||||
" (75, 0, 4),\n",
|
||||
" (102, 0, 5),\n",
|
||||
"]\n",
|
||||
"shop_rings = [\n",
|
||||
" NEUTRAL,\n",
|
||||
" NEUTRAL,\n",
|
||||
" (25, 1, 0),\n",
|
||||
" (50, 2, 0),\n",
|
||||
" (100, 3, 0),\n",
|
||||
" (20, 0, 1),\n",
|
||||
" (40, 0, 2),\n",
|
||||
" (80, 0, 3),\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"def fight(player_damage, player_armor):\n",
|
||||
" player = player_hp\n",
|
||||
" boss = boss_hp\n",
|
||||
" while True:\n",
|
||||
" boss -= max(1, player_damage - boss_armor)\n",
|
||||
" if boss <= 0:\n",
|
||||
" return True\n",
|
||||
" player -= max(1, boss_damage - player_armor)\n",
|
||||
" if player <= 0:\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"def combine(*args):\n",
|
||||
" return tuple(map(sum, zip(*args)))\n",
|
||||
" \n",
|
||||
"best = 1e1337\n",
|
||||
"for weapon in shop_weapons:\n",
|
||||
" for armor in shop_armor:\n",
|
||||
" for i, ring1 in enumerate(shop_rings):\n",
|
||||
" for ring2 in shop_rings[i+1:]:\n",
|
||||
" cost, d, a = combine(weapon, armor, ring1, ring2)\n",
|
||||
" if fight(d, a):\n",
|
||||
" best = min(best, cost)\n",
|
||||
"best"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"188"
|
||||
]
|
||||
},
|
||||
"execution_count": 44,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"best = 0\n",
|
||||
"for weapon in shop_weapons:\n",
|
||||
" for armor in shop_armor:\n",
|
||||
" for i, ring1 in enumerate(shop_rings):\n",
|
||||
" for ring2 in shop_rings[i+1:]:\n",
|
||||
" cost, d, a = combine(weapon, armor, ring1, ring2)\n",
|
||||
" if not fight(d, a):\n",
|
||||
" best = max(best, cost)\n",
|
||||
"best"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
54
Python/2015/21.py
Normal file
54
Python/2015/21.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 21)
|
||||
|
||||
(*_, boss_hp), (*_, boss_damage), (*_, boss_armor) = map(str.split, input.splitlines())
|
||||
|
||||
boss_hp, boss_damage, boss_armor = map(int, [boss_hp, boss_damage, boss_armor])
|
||||
|
||||
|
||||
player_hp = 100
|
||||
|
||||
|
||||
NEUTRAL = (0, 0, 0)
|
||||
shop_weapons = [(8, 4, 0), (10, 5, 0), (25, 6, 0), (40, 7, 0), (74, 8, 0)]
|
||||
shop_armor = [NEUTRAL, (13, 0, 1), (31, 0, 2), (53, 0, 3), (75, 0, 4), (102, 0, 5)]
|
||||
shop_rings = [NEUTRAL, NEUTRAL, (25, 1, 0), (50, 2, 0), (100, 3, 0), (20, 0, 1), (40, 0, 2), (80, 0, 3)]
|
||||
|
||||
|
||||
def fight(player_damage, player_armor):
|
||||
player = player_hp
|
||||
boss = boss_hp
|
||||
while True:
|
||||
boss -= max(1, player_damage - boss_armor)
|
||||
if boss <= 0:
|
||||
return True
|
||||
player -= max(1, boss_damage - player_armor)
|
||||
if player <= 0:
|
||||
return False
|
||||
|
||||
|
||||
def combine(*args):
|
||||
return tuple(map(sum, zip(*args)))
|
||||
|
||||
|
||||
best = 1e1337
|
||||
for weapon in shop_weapons:
|
||||
for armor in shop_armor:
|
||||
for i, ring1 in enumerate(shop_rings):
|
||||
for ring2 in shop_rings[i + 1 :]:
|
||||
cost, d, a = combine(weapon, armor, ring1, ring2)
|
||||
if fight(d, a):
|
||||
best = min(best, cost)
|
||||
print(best)
|
||||
|
||||
|
||||
best = 0
|
||||
for weapon in shop_weapons:
|
||||
for armor in shop_armor:
|
||||
for i, ring1 in enumerate(shop_rings):
|
||||
for ring2 in shop_rings[i + 1 :]:
|
||||
cost, d, a = combine(weapon, armor, ring1, ring2)
|
||||
if not fight(d, a):
|
||||
best = max(best, cost)
|
||||
print(best)
|
|
@ -1,213 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 22"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 22\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1824"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(*_, boss_hp), (*_, boss_damage) = map(str.split, puzzle.splitlines())\n",
|
||||
"boss_hp, boss_damage = map(int, [boss_hp, boss_damage])\n",
|
||||
"\n",
|
||||
"player_hp = 50\n",
|
||||
"player_mana = 500\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def tick(*timers):\n",
|
||||
" return [max(0, t - 1) for t in timers]\n",
|
||||
"\n",
|
||||
"def fight_boss(player, boss, mana, shield_timer, poison_timer, recharge_timer):\n",
|
||||
" armor = 7 if shield_timer else 0\n",
|
||||
" if poison_timer:\n",
|
||||
" boss -= 3\n",
|
||||
" if recharge_timer:\n",
|
||||
" mana += 101\n",
|
||||
" shield_timer, poison_timer, recharge_timer = tick(shield_timer, poison_timer, recharge_timer)\n",
|
||||
" \n",
|
||||
" if boss <= 0:\n",
|
||||
" return 0\n",
|
||||
"\n",
|
||||
" return fight_player(player - max(1, boss_damage - armor), boss, mana, shield_timer, poison_timer, recharge_timer)\n",
|
||||
"\n",
|
||||
"def fight_player(player, boss, mana, shield_timer, poison_timer, recharge_timer):\n",
|
||||
" if player <= 0:\n",
|
||||
" return None\n",
|
||||
" \n",
|
||||
" if poison_timer:\n",
|
||||
" boss -= 3\n",
|
||||
" if recharge_timer:\n",
|
||||
" mana += 101\n",
|
||||
" shield_timer, poison_timer, recharge_timer = tick(shield_timer, poison_timer, recharge_timer)\n",
|
||||
"\n",
|
||||
" if boss <= 0:\n",
|
||||
" return 0\n",
|
||||
"\n",
|
||||
" out = []\n",
|
||||
" \n",
|
||||
" # Magic Missile costs 53 mana. It instantly does 4 damage.\n",
|
||||
" if mana >= 53 and (x := fight_boss(player, boss - 4, mana - 53, shield_timer, poison_timer, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 53)\n",
|
||||
" \n",
|
||||
" # Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit points.\n",
|
||||
" if mana >= 73 and (x := fight_boss(player + 2, boss - 2, mana - 73, shield_timer, poison_timer, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 73)\n",
|
||||
"\n",
|
||||
" # Shield costs 113 mana. It starts an effect that lasts for 6 turns. \n",
|
||||
" # While it is active, your armor is increased by 7.\n",
|
||||
" if mana >= 113 and not shield_timer and (x := fight_boss(player, boss, mana - 113, 6, poison_timer, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 113)\n",
|
||||
" \n",
|
||||
" # Poison costs 173 mana. It starts an effect that lasts for 6 turns. \n",
|
||||
" # At the start of each turn while it is active, it deals the boss 3 damage.\n",
|
||||
" if mana >= 173 and not poison_timer and (x := fight_boss(player, boss, mana - 173, shield_timer, 6, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 173)\n",
|
||||
" \n",
|
||||
" # Recharge costs 229 mana. It starts an effect that lasts for 5 turns. \n",
|
||||
" # At the start of each turn while it is active, it gives you 101 new mana.\n",
|
||||
" if mana >= 229 and not recharge_timer and (x := fight_boss(player, boss, mana - 229, shield_timer, poison_timer, 5)) is not None:\n",
|
||||
" out.append(x + 229)\n",
|
||||
" \n",
|
||||
" return min(out, default=None)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"fight_player(player_hp, boss_hp, player_mana, 0, 0, 0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1937"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def fight_player(player, boss, mana, shield_timer, poison_timer, recharge_timer):\n",
|
||||
" player -= 1\n",
|
||||
" if player <= 0:\n",
|
||||
" return None\n",
|
||||
" \n",
|
||||
" if poison_timer:\n",
|
||||
" boss -= 3\n",
|
||||
" if recharge_timer:\n",
|
||||
" mana += 101\n",
|
||||
" shield_timer, poison_timer, recharge_timer = tick(shield_timer, poison_timer, recharge_timer)\n",
|
||||
"\n",
|
||||
" if boss <= 0:\n",
|
||||
" return 0\n",
|
||||
"\n",
|
||||
" out = []\n",
|
||||
" \n",
|
||||
" # Magic Missile costs 53 mana. It instantly does 4 damage.\n",
|
||||
" if mana >= 53 and (x := fight_boss(player, boss - 4, mana - 53, shield_timer, poison_timer, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 53)\n",
|
||||
" \n",
|
||||
" # Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit points.\n",
|
||||
" if mana >= 73 and (x := fight_boss(player + 2, boss - 2, mana - 73, shield_timer, poison_timer, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 73)\n",
|
||||
"\n",
|
||||
" # Shield costs 113 mana. It starts an effect that lasts for 6 turns. \n",
|
||||
" # While it is active, your armor is increased by 7.\n",
|
||||
" if mana >= 113 and not shield_timer and (x := fight_boss(player, boss, mana - 113, 6, poison_timer, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 113)\n",
|
||||
" \n",
|
||||
" # Poison costs 173 mana. It starts an effect that lasts for 6 turns. \n",
|
||||
" # At the start of each turn while it is active, it deals the boss 3 damage.\n",
|
||||
" if mana >= 173 and not poison_timer and (x := fight_boss(player, boss, mana - 173, shield_timer, 6, recharge_timer)) is not None:\n",
|
||||
" out.append(x + 173)\n",
|
||||
" \n",
|
||||
" # Recharge costs 229 mana. It starts an effect that lasts for 5 turns. \n",
|
||||
" # At the start of each turn while it is active, it gives you 101 new mana.\n",
|
||||
" if mana >= 229 and not recharge_timer and (x := fight_boss(player, boss, mana - 229, shield_timer, poison_timer, 5)) is not None:\n",
|
||||
" out.append(x + 229)\n",
|
||||
" \n",
|
||||
" return min(out, default=None)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"fight_player(player_hp, boss_hp, player_mana, 0, 0, 0)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
178
Python/2015/22.py
Normal file
178
Python/2015/22.py
Normal file
|
@ -0,0 +1,178 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 22)
|
||||
|
||||
(*_, boss_hp), (*_, boss_damage) = map(str.split, input.splitlines())
|
||||
|
||||
boss_hp, boss_damage = map(int, [boss_hp, boss_damage])
|
||||
|
||||
|
||||
player_hp = 50
|
||||
player_mana = 500
|
||||
|
||||
|
||||
def tick(*timers):
|
||||
return [max(0, t - 1) for t in timers]
|
||||
|
||||
|
||||
def fight_boss(player, boss, mana, shield_timer, poison_timer, recharge_timer):
|
||||
armor = 7 if shield_timer else 0
|
||||
|
||||
if poison_timer:
|
||||
boss -= 3
|
||||
|
||||
if recharge_timer:
|
||||
mana += 101
|
||||
|
||||
shield_timer, poison_timer, recharge_timer = tick(shield_timer, poison_timer, recharge_timer)
|
||||
|
||||
if boss <= 0:
|
||||
return 0
|
||||
|
||||
return fight_player(player - max(1, boss_damage - armor), boss, mana, shield_timer, poison_timer, recharge_timer)
|
||||
|
||||
|
||||
def fight_player(player, boss, mana, shield_timer, poison_timer, recharge_timer):
|
||||
if player <= 0:
|
||||
return None
|
||||
|
||||
if poison_timer:
|
||||
boss -= 3
|
||||
|
||||
if recharge_timer:
|
||||
mana += 101
|
||||
|
||||
shield_timer, poison_timer, recharge_timer = tick(shield_timer, poison_timer, recharge_timer)
|
||||
|
||||
if boss <= 0:
|
||||
return 0
|
||||
|
||||
out = []
|
||||
|
||||
# Magic Missile costs 53 mana. It instantly does 4 damage.
|
||||
|
||||
if (
|
||||
mana >= 53
|
||||
and (x := fight_boss(player, boss - 4, mana - 53, shield_timer, poison_timer, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 53)
|
||||
|
||||
# Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit points.
|
||||
|
||||
if (
|
||||
mana >= 73
|
||||
and (x := fight_boss(player + 2, boss - 2, mana - 73, shield_timer, poison_timer, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 73)
|
||||
|
||||
# Shield costs 113 mana. It starts an effect that lasts for 6 turns.
|
||||
|
||||
# While it is active, your armor is increased by 7.
|
||||
|
||||
if (
|
||||
mana >= 113
|
||||
and not shield_timer
|
||||
and (x := fight_boss(player, boss, mana - 113, 6, poison_timer, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 113)
|
||||
|
||||
# Poison costs 173 mana. It starts an effect that lasts for 6 turns.
|
||||
|
||||
# At the start of each turn while it is active, it deals the boss 3 damage.
|
||||
|
||||
if (
|
||||
mana >= 173
|
||||
and not poison_timer
|
||||
and (x := fight_boss(player, boss, mana - 173, shield_timer, 6, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 173)
|
||||
|
||||
# Recharge costs 229 mana. It starts an effect that lasts for 5 turns.
|
||||
|
||||
# At the start of each turn while it is active, it gives you 101 new mana.
|
||||
|
||||
if (
|
||||
mana >= 229
|
||||
and not recharge_timer
|
||||
and (x := fight_boss(player, boss, mana - 229, shield_timer, poison_timer, 5)) is not None
|
||||
):
|
||||
out.append(x + 229)
|
||||
|
||||
return min(out, default=None)
|
||||
|
||||
|
||||
print(fight_player(player_hp, boss_hp, player_mana, 0, 0, 0))
|
||||
|
||||
|
||||
def fight_player(player, boss, mana, shield_timer, poison_timer, recharge_timer):
|
||||
player -= 1
|
||||
|
||||
if player <= 0:
|
||||
return None
|
||||
|
||||
if poison_timer:
|
||||
boss -= 3
|
||||
|
||||
if recharge_timer:
|
||||
mana += 101
|
||||
|
||||
shield_timer, poison_timer, recharge_timer = tick(shield_timer, poison_timer, recharge_timer)
|
||||
|
||||
if boss <= 0:
|
||||
return 0
|
||||
|
||||
out = []
|
||||
|
||||
# Magic Missile costs 53 mana. It instantly does 4 damage.
|
||||
|
||||
if (
|
||||
mana >= 53
|
||||
and (x := fight_boss(player, boss - 4, mana - 53, shield_timer, poison_timer, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 53)
|
||||
|
||||
# Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit points.
|
||||
|
||||
if (
|
||||
mana >= 73
|
||||
and (x := fight_boss(player + 2, boss - 2, mana - 73, shield_timer, poison_timer, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 73)
|
||||
|
||||
# Shield costs 113 mana. It starts an effect that lasts for 6 turns.
|
||||
|
||||
# While it is active, your armor is increased by 7.
|
||||
|
||||
if (
|
||||
mana >= 113
|
||||
and not shield_timer
|
||||
and (x := fight_boss(player, boss, mana - 113, 6, poison_timer, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 113)
|
||||
|
||||
# Poison costs 173 mana. It starts an effect that lasts for 6 turns.
|
||||
|
||||
# At the start of each turn while it is active, it deals the boss 3 damage.
|
||||
|
||||
if (
|
||||
mana >= 173
|
||||
and not poison_timer
|
||||
and (x := fight_boss(player, boss, mana - 173, shield_timer, 6, recharge_timer)) is not None
|
||||
):
|
||||
out.append(x + 173)
|
||||
|
||||
# Recharge costs 229 mana. It starts an effect that lasts for 5 turns.
|
||||
|
||||
# At the start of each turn while it is active, it gives you 101 new mana.
|
||||
|
||||
if (
|
||||
mana >= 229
|
||||
and not recharge_timer
|
||||
and (x := fight_boss(player, boss, mana - 229, shield_timer, poison_timer, 5)) is not None
|
||||
):
|
||||
out.append(x + 229)
|
||||
|
||||
return min(out, default=None)
|
||||
|
||||
|
||||
print(fight_player(player_hp, boss_hp, player_mana, 0, 0, 0))
|
|
@ -1,154 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 23"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 23\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"170"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"program = puzzle.splitlines()\n",
|
||||
"pc = 0\n",
|
||||
"registers = {\"a\": 0, \"b\": 0}\n",
|
||||
"while pc < len(program):\n",
|
||||
" cmd, args = program[pc].split(maxsplit=1)\n",
|
||||
" args = args.split(\", \")\n",
|
||||
" if cmd == \"hlf\":\n",
|
||||
" registers[args[0]] //= 2\n",
|
||||
" pc += 1\n",
|
||||
" elif cmd == \"tpl\":\n",
|
||||
" registers[args[0]] *= 3\n",
|
||||
" pc += 1\n",
|
||||
" elif cmd == \"inc\":\n",
|
||||
" registers[args[0]] += 1\n",
|
||||
" pc += 1\n",
|
||||
" elif cmd == \"jmp\":\n",
|
||||
" pc += int(args[0])\n",
|
||||
" elif cmd == \"jie\":\n",
|
||||
" pc += int(args[1]) if registers[args[0]] % 2 == 0 else 1\n",
|
||||
" elif cmd == \"jio\":\n",
|
||||
" pc += int(args[1]) if registers[args[0]] == 1 else 1\n",
|
||||
" else:\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
"registers[\"b\"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"247"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"pc = 0\n",
|
||||
"registers = {\"a\": 1, \"b\": 0}\n",
|
||||
"while pc < len(program):\n",
|
||||
" cmd, args = program[pc].split(maxsplit=1)\n",
|
||||
" args = args.split(\", \")\n",
|
||||
" if cmd == \"hlf\":\n",
|
||||
" registers[args[0]] //= 2\n",
|
||||
" pc += 1\n",
|
||||
" elif cmd == \"tpl\":\n",
|
||||
" registers[args[0]] *= 3\n",
|
||||
" pc += 1\n",
|
||||
" elif cmd == \"inc\":\n",
|
||||
" registers[args[0]] += 1\n",
|
||||
" pc += 1\n",
|
||||
" elif cmd == \"jmp\":\n",
|
||||
" pc += int(args[0])\n",
|
||||
" elif cmd == \"jie\":\n",
|
||||
" pc += int(args[1]) if registers[args[0]] % 2 == 0 else 1\n",
|
||||
" elif cmd == \"jio\":\n",
|
||||
" pc += int(args[1]) if registers[args[0]] == 1 else 1\n",
|
||||
" else:\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
"registers[\"b\"]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
56
Python/2015/23.py
Normal file
56
Python/2015/23.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 23)
|
||||
|
||||
program = input.splitlines()
|
||||
|
||||
pc = 0
|
||||
registers = {"a": 0, "b": 0}
|
||||
while pc < len(program):
|
||||
cmd, args = program[pc].split(maxsplit=1)
|
||||
args = args.split(", ")
|
||||
if cmd == "hlf":
|
||||
registers[args[0]] //= 2
|
||||
pc += 1
|
||||
elif cmd == "tpl":
|
||||
registers[args[0]] *= 3
|
||||
pc += 1
|
||||
elif cmd == "inc":
|
||||
registers[args[0]] += 1
|
||||
pc += 1
|
||||
elif cmd == "jmp":
|
||||
pc += int(args[0])
|
||||
elif cmd == "jie":
|
||||
pc += int(args[1]) if registers[args[0]] % 2 == 0 else 1
|
||||
elif cmd == "jio":
|
||||
pc += int(args[1]) if registers[args[0]] == 1 else 1
|
||||
else:
|
||||
break
|
||||
|
||||
print(registers["b"])
|
||||
|
||||
|
||||
pc = 0
|
||||
registers = {"a": 1, "b": 0}
|
||||
while pc < len(program):
|
||||
cmd, args = program[pc].split(maxsplit=1)
|
||||
args = args.split(", ")
|
||||
if cmd == "hlf":
|
||||
registers[args[0]] //= 2
|
||||
pc += 1
|
||||
elif cmd == "tpl":
|
||||
registers[args[0]] *= 3
|
||||
pc += 1
|
||||
elif cmd == "inc":
|
||||
registers[args[0]] += 1
|
||||
pc += 1
|
||||
elif cmd == "jmp":
|
||||
pc += int(args[0])
|
||||
elif cmd == "jie":
|
||||
pc += int(args[1]) if registers[args[0]] % 2 == 0 else 1
|
||||
elif cmd == "jio":
|
||||
pc += int(args[1]) if registers[args[0]] == 1 else 1
|
||||
else:
|
||||
break
|
||||
|
||||
print(registers["b"])
|
|
@ -1,159 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 24"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 24\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"11266889531"
|
||||
]
|
||||
},
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"packages = list(map(int, puzzle.splitlines()))\n",
|
||||
"gs = sum(packages) // 3\n",
|
||||
"\n",
|
||||
"dp = {}\n",
|
||||
"def test(i, x, pkg):\n",
|
||||
" if x == 0:\n",
|
||||
" return [[]]\n",
|
||||
" if i == len(pkg):\n",
|
||||
" return []\n",
|
||||
" \n",
|
||||
" if (i, x) not in dp:\n",
|
||||
" out = [[0] + y for y in test(i + 1, x, pkg)]\n",
|
||||
" if packages[i] <= x:\n",
|
||||
" out += [[1] + y for y in test(i + 1, x - pkg[i], pkg)]\n",
|
||||
" dp[(i, x)] = out\n",
|
||||
" return dp[(i, x)]\n",
|
||||
"\n",
|
||||
"arr = []\n",
|
||||
"for x in test(0, gs, packages):\n",
|
||||
" f = [z for y, z in zip(x, packages) if y]\n",
|
||||
" if not test(0, gs, f):\n",
|
||||
" continue\n",
|
||||
" p = 1\n",
|
||||
" for y in f:\n",
|
||||
" p *= y\n",
|
||||
" arr.append((len(f), p))\n",
|
||||
"min(arr)[1]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"77387711"
|
||||
]
|
||||
},
|
||||
"execution_count": 40,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"packages = list(map(int, puzzle.splitlines()))\n",
|
||||
"gs = sum(packages) // 4\n",
|
||||
"\n",
|
||||
"dp = {}\n",
|
||||
"def test(i, x, pkg):\n",
|
||||
" if x == 0:\n",
|
||||
" return [[]]\n",
|
||||
" if i == len(pkg):\n",
|
||||
" return []\n",
|
||||
" \n",
|
||||
" if (i, x) not in dp:\n",
|
||||
" out = [[0] + y for y in test(i + 1, x, pkg)]\n",
|
||||
" if packages[i] <= x:\n",
|
||||
" out += [[1] + y for y in test(i + 1, x - pkg[i], pkg)]\n",
|
||||
" dp[(i, x)] = out\n",
|
||||
" return dp[(i, x)]\n",
|
||||
"\n",
|
||||
"arr = []\n",
|
||||
"for x in test(0, gs, packages):\n",
|
||||
" f = [z for y, z in zip(x, packages) if y]\n",
|
||||
" if not test(0, gs, f):\n",
|
||||
" continue\n",
|
||||
" p = 1\n",
|
||||
" for y in f:\n",
|
||||
" p *= y\n",
|
||||
" arr.append((len(f), p))\n",
|
||||
"min(arr)[1]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
67
Python/2015/24.py
Normal file
67
Python/2015/24.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 24)
|
||||
|
||||
packages = list(map(int, input.splitlines()))
|
||||
|
||||
gs = sum(packages) // 3
|
||||
|
||||
|
||||
dp = {}
|
||||
|
||||
|
||||
def test(i, x, pkg):
|
||||
if x == 0:
|
||||
return [[]]
|
||||
if i == len(pkg):
|
||||
return []
|
||||
if (i, x) not in dp:
|
||||
out = [[0] + y for y in test(i + 1, x, pkg)]
|
||||
if packages[i] <= x:
|
||||
out += [[1] + y for y in test(i + 1, x - pkg[i], pkg)]
|
||||
dp[(i, x)] = out
|
||||
return dp[(i, x)]
|
||||
|
||||
|
||||
arr = []
|
||||
for x in test(0, gs, packages):
|
||||
f = [z for y, z in zip(x, packages) if y]
|
||||
if not test(0, gs, f):
|
||||
continue
|
||||
p = 1
|
||||
for y in f:
|
||||
p *= y
|
||||
arr.append((len(f), p))
|
||||
|
||||
print(min(arr)[1])
|
||||
|
||||
|
||||
packages = list(map(int, input.splitlines()))
|
||||
gs = sum(packages) // 4
|
||||
dp = {}
|
||||
|
||||
|
||||
def test(i, x, pkg):
|
||||
if x == 0:
|
||||
return [[]]
|
||||
if i == len(pkg):
|
||||
return []
|
||||
if (i, x) not in dp:
|
||||
out = [[0] + y for y in test(i + 1, x, pkg)]
|
||||
if packages[i] <= x:
|
||||
out += [[1] + y for y in test(i + 1, x - pkg[i], pkg)]
|
||||
dp[(i, x)] = out
|
||||
return dp[(i, x)]
|
||||
|
||||
|
||||
arr = []
|
||||
for x in test(0, gs, packages):
|
||||
f = [z for y, z in zip(x, packages) if y]
|
||||
if not test(0, gs, f):
|
||||
continue
|
||||
p = 1
|
||||
for y in f:
|
||||
p *= y
|
||||
arr.append((len(f), p))
|
||||
|
||||
print(min(arr)[1])
|
|
@ -1,99 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/markdown": [
|
||||
"# Day 25"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Markdown object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sys; sys.path.insert(0, \"..\")\n",
|
||||
"\n",
|
||||
"import aoc\n",
|
||||
"\n",
|
||||
"year, day = 2015, 25\n",
|
||||
"\n",
|
||||
"puzzle = aoc.setup(year, day)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"19980801"
|
||||
]
|
||||
},
|
||||
"execution_count": 33,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import re\n",
|
||||
"\n",
|
||||
"row, col = map(int, re.match(r\"^.*?(\\d+).*?(\\d+).*?$\", puzzle).groups())\n",
|
||||
"\n",
|
||||
"n = (row + col - 2)\n",
|
||||
"(20151125 * pow(252533, n * (n + 1) // 2 + 1 + col - 2, 33554393)) % 33554393"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Puzzle 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
9
Python/2015/25.py
Normal file
9
Python/2015/25.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from lib import *
|
||||
|
||||
input = read_input(2015, 25)
|
||||
|
||||
row, col = map(int, re.match(r"^.*?(\d+).*?(\d+).*?$", input).groups())
|
||||
|
||||
|
||||
n = row + col - 2
|
||||
print((20151125 * pow(252533, n * (n + 1) // 2 + 1 + col - 2, 33554393)) % 33554393)
|
|
@ -11,6 +11,7 @@ import bisect
|
|||
import collections
|
||||
import functools
|
||||
import graphlib
|
||||
import hashlib
|
||||
import heapq
|
||||
import io
|
||||
import itertools
|
||||
|
|
32
README.md
32
README.md
|
@ -43,34 +43,34 @@
|
|||
|-|-|-|-|-|-|-|
|
||||
||||||[**1**](https://adventofcode.com/2018/day/1) [<img height=12 src=".assets/py.svg">](Python/2018/01 "Python solution for 2018/01")|[**2**](https://adventofcode.com/2018/day/2) [<img height=12 src=".assets/py.svg">](Python/2018/02 "Python solution for 2018/02")|
|
||||
|[**3**](https://adventofcode.com/2018/day/3) [<img height=12 src=".assets/py.svg">](Python/2018/03 "Python solution for 2018/03")|[**4**](https://adventofcode.com/2018/day/4) [<img height=12 src=".assets/py.svg">](Python/2018/04 "Python solution for 2018/04")|[**5**](https://adventofcode.com/2018/day/5) [<img height=12 src=".assets/py.svg">](Python/2018/05 "Python solution for 2018/05")|[**6**](https://adventofcode.com/2018/day/6) [<img height=12 src=".assets/py.svg">](Python/2018/06 "Python solution for 2018/06")|[**7**](https://adventofcode.com/2018/day/7) [<img height=12 src=".assets/py.svg">](Python/2018/07 "Python solution for 2018/07")|[**8**](https://adventofcode.com/2018/day/8) [<img height=12 src=".assets/py.svg">](Python/2018/08 "Python solution for 2018/08")|[**9**](https://adventofcode.com/2018/day/9) [<img height=12 src=".assets/py.svg">](Python/2018/09 "Python solution for 2018/09")|
|
||||
|[**10**](https://adventofcode.com/2018/day/10) [<img height=12 src=".assets/py.svg">](Python/2018/10 "Python solution for 2018/10")|[**11**](https://adventofcode.com/2018/day/11) [<img height=12 src=".assets/py.svg">](Python/2018/11.ipynb "Python solution for 2018/11")|[**12**](https://adventofcode.com/2018/day/12) [<img height=12 src=".assets/py.svg">](Python/2018/12.ipynb "Python solution for 2018/12")|[**13**](https://adventofcode.com/2018/day/13) [<img height=12 src=".assets/py.svg">](Python/2018/13.ipynb "Python solution for 2018/13")|[**14**](https://adventofcode.com/2018/day/14) [<img height=12 src=".assets/py.svg">](Python/2018/14.ipynb "Python solution for 2018/14")|[**15**](https://adventofcode.com/2018/day/15) [<img height=12 src=".assets/py.svg">](Python/2018/15.ipynb "Python solution for 2018/15")|[**16**](https://adventofcode.com/2018/day/16) [<img height=12 src=".assets/py.svg">](Python/2018/16.ipynb "Python solution for 2018/16")|
|
||||
|[**17**](https://adventofcode.com/2018/day/17) [<img height=12 src=".assets/py.svg">](Python/2018/17.ipynb "Python solution for 2018/17")|[**18**](https://adventofcode.com/2018/day/18) [<img height=12 src=".assets/py.svg">](Python/2018/18.ipynb "Python solution for 2018/18")|[**19**](https://adventofcode.com/2018/day/19) [<img height=12 src=".assets/py.svg">](Python/2018/19.ipynb "Python solution for 2018/19")|[**20**](https://adventofcode.com/2018/day/20) [<img height=12 src=".assets/py.svg">](Python/2018/20.ipynb "Python solution for 2018/20")|[**21**](https://adventofcode.com/2018/day/21) [<img height=12 src=".assets/py.svg">](Python/2018/21.ipynb "Python solution for 2018/21")|[**22**](https://adventofcode.com/2018/day/22) [<img height=12 src=".assets/py.svg">](Python/2018/22.ipynb "Python solution for 2018/22")|[**23**](https://adventofcode.com/2018/day/23) [<img height=12 src=".assets/py.svg">](Python/2018/23.ipynb "Python solution for 2018/23")|
|
||||
|[**24**](https://adventofcode.com/2018/day/24) [<img height=12 src=".assets/py.svg">](Python/2018/24.ipynb "Python solution for 2018/24")|[**25**](https://adventofcode.com/2018/day/25) [<img height=12 src=".assets/py.svg">](Python/2018/25.ipynb "Python solution for 2018/25")|26|27|28|29|30|
|
||||
|[**10**](https://adventofcode.com/2018/day/10) [<img height=12 src=".assets/py.svg">](Python/2018/10 "Python solution for 2018/10")|[**11**](https://adventofcode.com/2018/day/11) [<img height=12 src=".assets/py.svg">](Python/2018/11.py "Python solution for 2018/11")|[**12**](https://adventofcode.com/2018/day/12) [<img height=12 src=".assets/py.svg">](Python/2018/12.py "Python solution for 2018/12")|[**13**](https://adventofcode.com/2018/day/13) [<img height=12 src=".assets/py.svg">](Python/2018/13.py "Python solution for 2018/13")|[**14**](https://adventofcode.com/2018/day/14) [<img height=12 src=".assets/py.svg">](Python/2018/14.py "Python solution for 2018/14")|[**15**](https://adventofcode.com/2018/day/15) [<img height=12 src=".assets/py.svg">](Python/2018/15.py "Python solution for 2018/15")|[**16**](https://adventofcode.com/2018/day/16) [<img height=12 src=".assets/py.svg">](Python/2018/16.py "Python solution for 2018/16")|
|
||||
|[**17**](https://adventofcode.com/2018/day/17) [<img height=12 src=".assets/py.svg">](Python/2018/17.py "Python solution for 2018/17")|[**18**](https://adventofcode.com/2018/day/18) [<img height=12 src=".assets/py.svg">](Python/2018/18.py "Python solution for 2018/18")|[**19**](https://adventofcode.com/2018/day/19) [<img height=12 src=".assets/py.svg">](Python/2018/19.py "Python solution for 2018/19")|[**20**](https://adventofcode.com/2018/day/20) [<img height=12 src=".assets/py.svg">](Python/2018/20.py "Python solution for 2018/20")|[**21**](https://adventofcode.com/2018/day/21) [<img height=12 src=".assets/py.svg">](Python/2018/21.py "Python solution for 2018/21")|[**22**](https://adventofcode.com/2018/day/22) [<img height=12 src=".assets/py.svg">](Python/2018/22.py "Python solution for 2018/22")|[**23**](https://adventofcode.com/2018/day/23) [<img height=12 src=".assets/py.svg">](Python/2018/23.py "Python solution for 2018/23")|
|
||||
|[**24**](https://adventofcode.com/2018/day/24) [<img height=12 src=".assets/py.svg">](Python/2018/24.py "Python solution for 2018/24")|[**25**](https://adventofcode.com/2018/day/25) [<img height=12 src=".assets/py.svg">](Python/2018/25.py "Python solution for 2018/25")|26|27|28|29|30|
|
||||
|31|||||||
|
||||
|
||||
## [2017](https://adventofcode.com/2017) ([<img height=18 src=".assets/py.svg"> Python](Python/2017): 25/25)
|
||||
|Mo|Tu|We|Th|Fr|Sa|Su|
|
||||
|-|-|-|-|-|-|-|
|
||||
|||||[**1**](https://adventofcode.com/2017/day/1) [<img height=12 src=".assets/py.svg">](Python/2017/01.ipynb "Python solution for 2017/01")|[**2**](https://adventofcode.com/2017/day/2) [<img height=12 src=".assets/py.svg">](Python/2017/02.ipynb "Python solution for 2017/02")|[**3**](https://adventofcode.com/2017/day/3) [<img height=12 src=".assets/py.svg">](Python/2017/03.ipynb "Python solution for 2017/03")|
|
||||
|[**4**](https://adventofcode.com/2017/day/4) [<img height=12 src=".assets/py.svg">](Python/2017/04.ipynb "Python solution for 2017/04")|[**5**](https://adventofcode.com/2017/day/5) [<img height=12 src=".assets/py.svg">](Python/2017/05.ipynb "Python solution for 2017/05")|[**6**](https://adventofcode.com/2017/day/6) [<img height=12 src=".assets/py.svg">](Python/2017/06.ipynb "Python solution for 2017/06")|[**7**](https://adventofcode.com/2017/day/7) [<img height=12 src=".assets/py.svg">](Python/2017/07.ipynb "Python solution for 2017/07")|[**8**](https://adventofcode.com/2017/day/8) [<img height=12 src=".assets/py.svg">](Python/2017/08.ipynb "Python solution for 2017/08")|[**9**](https://adventofcode.com/2017/day/9) [<img height=12 src=".assets/py.svg">](Python/2017/09.ipynb "Python solution for 2017/09")|[**10**](https://adventofcode.com/2017/day/10) [<img height=12 src=".assets/py.svg">](Python/2017/10.ipynb "Python solution for 2017/10")|
|
||||
|[**11**](https://adventofcode.com/2017/day/11) [<img height=12 src=".assets/py.svg">](Python/2017/11.ipynb "Python solution for 2017/11")|[**12**](https://adventofcode.com/2017/day/12) [<img height=12 src=".assets/py.svg">](Python/2017/12.ipynb "Python solution for 2017/12")|[**13**](https://adventofcode.com/2017/day/13) [<img height=12 src=".assets/py.svg">](Python/2017/13.ipynb "Python solution for 2017/13")|[**14**](https://adventofcode.com/2017/day/14) [<img height=12 src=".assets/py.svg">](Python/2017/14.ipynb "Python solution for 2017/14")|[**15**](https://adventofcode.com/2017/day/15) [<img height=12 src=".assets/py.svg">](Python/2017/15.ipynb "Python solution for 2017/15")|[**16**](https://adventofcode.com/2017/day/16) [<img height=12 src=".assets/py.svg">](Python/2017/16.ipynb "Python solution for 2017/16")|[**17**](https://adventofcode.com/2017/day/17) [<img height=12 src=".assets/py.svg">](Python/2017/17.ipynb "Python solution for 2017/17")|
|
||||
|[**18**](https://adventofcode.com/2017/day/18) [<img height=12 src=".assets/py.svg">](Python/2017/18.ipynb "Python solution for 2017/18")|[**19**](https://adventofcode.com/2017/day/19) [<img height=12 src=".assets/py.svg">](Python/2017/19.ipynb "Python solution for 2017/19")|[**20**](https://adventofcode.com/2017/day/20) [<img height=12 src=".assets/py.svg">](Python/2017/20.ipynb "Python solution for 2017/20")|[**21**](https://adventofcode.com/2017/day/21) [<img height=12 src=".assets/py.svg">](Python/2017/21.ipynb "Python solution for 2017/21")|[**22**](https://adventofcode.com/2017/day/22) [<img height=12 src=".assets/py.svg">](Python/2017/22.ipynb "Python solution for 2017/22")|[**23**](https://adventofcode.com/2017/day/23) [<img height=12 src=".assets/py.svg">](Python/2017/23.ipynb "Python solution for 2017/23")|[**24**](https://adventofcode.com/2017/day/24) [<img height=12 src=".assets/py.svg">](Python/2017/24.ipynb "Python solution for 2017/24")|
|
||||
|[**25**](https://adventofcode.com/2017/day/25) [<img height=12 src=".assets/py.svg">](Python/2017/25.ipynb "Python solution for 2017/25")|26|27|28|29|30|31|
|
||||
|||||[**1**](https://adventofcode.com/2017/day/1) [<img height=12 src=".assets/py.svg">](Python/2017/01.py "Python solution for 2017/01")|[**2**](https://adventofcode.com/2017/day/2) [<img height=12 src=".assets/py.svg">](Python/2017/02.py "Python solution for 2017/02")|[**3**](https://adventofcode.com/2017/day/3) [<img height=12 src=".assets/py.svg">](Python/2017/03.py "Python solution for 2017/03")|
|
||||
|[**4**](https://adventofcode.com/2017/day/4) [<img height=12 src=".assets/py.svg">](Python/2017/04.py "Python solution for 2017/04")|[**5**](https://adventofcode.com/2017/day/5) [<img height=12 src=".assets/py.svg">](Python/2017/05.py "Python solution for 2017/05")|[**6**](https://adventofcode.com/2017/day/6) [<img height=12 src=".assets/py.svg">](Python/2017/06.py "Python solution for 2017/06")|[**7**](https://adventofcode.com/2017/day/7) [<img height=12 src=".assets/py.svg">](Python/2017/07.py "Python solution for 2017/07")|[**8**](https://adventofcode.com/2017/day/8) [<img height=12 src=".assets/py.svg">](Python/2017/08.py "Python solution for 2017/08")|[**9**](https://adventofcode.com/2017/day/9) [<img height=12 src=".assets/py.svg">](Python/2017/09.py "Python solution for 2017/09")|[**10**](https://adventofcode.com/2017/day/10) [<img height=12 src=".assets/py.svg">](Python/2017/10.py "Python solution for 2017/10")|
|
||||
|[**11**](https://adventofcode.com/2017/day/11) [<img height=12 src=".assets/py.svg">](Python/2017/11.py "Python solution for 2017/11")|[**12**](https://adventofcode.com/2017/day/12) [<img height=12 src=".assets/py.svg">](Python/2017/12.py "Python solution for 2017/12")|[**13**](https://adventofcode.com/2017/day/13) [<img height=12 src=".assets/py.svg">](Python/2017/13.py "Python solution for 2017/13")|[**14**](https://adventofcode.com/2017/day/14) [<img height=12 src=".assets/py.svg">](Python/2017/14.py "Python solution for 2017/14")|[**15**](https://adventofcode.com/2017/day/15) [<img height=12 src=".assets/py.svg">](Python/2017/15.py "Python solution for 2017/15")|[**16**](https://adventofcode.com/2017/day/16) [<img height=12 src=".assets/py.svg">](Python/2017/16.py "Python solution for 2017/16")|[**17**](https://adventofcode.com/2017/day/17) [<img height=12 src=".assets/py.svg">](Python/2017/17.py "Python solution for 2017/17")|
|
||||
|[**18**](https://adventofcode.com/2017/day/18) [<img height=12 src=".assets/py.svg">](Python/2017/18.py "Python solution for 2017/18")|[**19**](https://adventofcode.com/2017/day/19) [<img height=12 src=".assets/py.svg">](Python/2017/19.py "Python solution for 2017/19")|[**20**](https://adventofcode.com/2017/day/20) [<img height=12 src=".assets/py.svg">](Python/2017/20.py "Python solution for 2017/20")|[**21**](https://adventofcode.com/2017/day/21) [<img height=12 src=".assets/py.svg">](Python/2017/21.py "Python solution for 2017/21")|[**22**](https://adventofcode.com/2017/day/22) [<img height=12 src=".assets/py.svg">](Python/2017/22.py "Python solution for 2017/22")|[**23**](https://adventofcode.com/2017/day/23) [<img height=12 src=".assets/py.svg">](Python/2017/23.py "Python solution for 2017/23")|[**24**](https://adventofcode.com/2017/day/24) [<img height=12 src=".assets/py.svg">](Python/2017/24.py "Python solution for 2017/24")|
|
||||
|[**25**](https://adventofcode.com/2017/day/25) [<img height=12 src=".assets/py.svg">](Python/2017/25.py "Python solution for 2017/25")|26|27|28|29|30|31|
|
||||
|
||||
## [2016](https://adventofcode.com/2016) ([<img height=18 src=".assets/py.svg"> Python](Python/2016): 25/25)
|
||||
|Mo|Tu|We|Th|Fr|Sa|Su|
|
||||
|-|-|-|-|-|-|-|
|
||||
||||[**1**](https://adventofcode.com/2016/day/1) [<img height=12 src=".assets/py.svg">](Python/2016/01.ipynb "Python solution for 2016/01")|[**2**](https://adventofcode.com/2016/day/2) [<img height=12 src=".assets/py.svg">](Python/2016/02.ipynb "Python solution for 2016/02")|[**3**](https://adventofcode.com/2016/day/3) [<img height=12 src=".assets/py.svg">](Python/2016/03.ipynb "Python solution for 2016/03")|[**4**](https://adventofcode.com/2016/day/4) [<img height=12 src=".assets/py.svg">](Python/2016/04.ipynb "Python solution for 2016/04")|
|
||||
|[**5**](https://adventofcode.com/2016/day/5) [<img height=12 src=".assets/py.svg">](Python/2016/05.ipynb "Python solution for 2016/05")|[**6**](https://adventofcode.com/2016/day/6) [<img height=12 src=".assets/py.svg">](Python/2016/06.ipynb "Python solution for 2016/06")|[**7**](https://adventofcode.com/2016/day/7) [<img height=12 src=".assets/py.svg">](Python/2016/07.ipynb "Python solution for 2016/07")|[**8**](https://adventofcode.com/2016/day/8) [<img height=12 src=".assets/py.svg">](Python/2016/08.ipynb "Python solution for 2016/08")|[**9**](https://adventofcode.com/2016/day/9) [<img height=12 src=".assets/py.svg">](Python/2016/09.ipynb "Python solution for 2016/09")|[**10**](https://adventofcode.com/2016/day/10) [<img height=12 src=".assets/py.svg">](Python/2016/10.ipynb "Python solution for 2016/10")|[**11**](https://adventofcode.com/2016/day/11) [<img height=12 src=".assets/py.svg">](Python/2016/11.ipynb "Python solution for 2016/11")|
|
||||
|[**12**](https://adventofcode.com/2016/day/12) [<img height=12 src=".assets/py.svg">](Python/2016/12.ipynb "Python solution for 2016/12")|[**13**](https://adventofcode.com/2016/day/13) [<img height=12 src=".assets/py.svg">](Python/2016/13.ipynb "Python solution for 2016/13")|[**14**](https://adventofcode.com/2016/day/14) [<img height=12 src=".assets/py.svg">](Python/2016/14.ipynb "Python solution for 2016/14")|[**15**](https://adventofcode.com/2016/day/15) [<img height=12 src=".assets/py.svg">](Python/2016/15.ipynb "Python solution for 2016/15")|[**16**](https://adventofcode.com/2016/day/16) [<img height=12 src=".assets/py.svg">](Python/2016/16.ipynb "Python solution for 2016/16")|[**17**](https://adventofcode.com/2016/day/17) [<img height=12 src=".assets/py.svg">](Python/2016/17.ipynb "Python solution for 2016/17")|[**18**](https://adventofcode.com/2016/day/18) [<img height=12 src=".assets/py.svg">](Python/2016/18.ipynb "Python solution for 2016/18")|
|
||||
|[**19**](https://adventofcode.com/2016/day/19) [<img height=12 src=".assets/py.svg">](Python/2016/19.ipynb "Python solution for 2016/19")|[**20**](https://adventofcode.com/2016/day/20) [<img height=12 src=".assets/py.svg">](Python/2016/20.ipynb "Python solution for 2016/20")|[**21**](https://adventofcode.com/2016/day/21) [<img height=12 src=".assets/py.svg">](Python/2016/21.ipynb "Python solution for 2016/21")|[**22**](https://adventofcode.com/2016/day/22) [<img height=12 src=".assets/py.svg">](Python/2016/22.ipynb "Python solution for 2016/22")|[**23**](https://adventofcode.com/2016/day/23) [<img height=12 src=".assets/py.svg">](Python/2016/23.ipynb "Python solution for 2016/23")|[**24**](https://adventofcode.com/2016/day/24) [<img height=12 src=".assets/py.svg">](Python/2016/24.ipynb "Python solution for 2016/24")|[**25**](https://adventofcode.com/2016/day/25) [<img height=12 src=".assets/py.svg">](Python/2016/25.ipynb "Python solution for 2016/25")|
|
||||
||||[**1**](https://adventofcode.com/2016/day/1) [<img height=12 src=".assets/py.svg">](Python/2016/01.py "Python solution for 2016/01")|[**2**](https://adventofcode.com/2016/day/2) [<img height=12 src=".assets/py.svg">](Python/2016/02.py "Python solution for 2016/02")|[**3**](https://adventofcode.com/2016/day/3) [<img height=12 src=".assets/py.svg">](Python/2016/03.py "Python solution for 2016/03")|[**4**](https://adventofcode.com/2016/day/4) [<img height=12 src=".assets/py.svg">](Python/2016/04.py "Python solution for 2016/04")|
|
||||
|[**5**](https://adventofcode.com/2016/day/5) [<img height=12 src=".assets/py.svg">](Python/2016/05.py "Python solution for 2016/05")|[**6**](https://adventofcode.com/2016/day/6) [<img height=12 src=".assets/py.svg">](Python/2016/06.py "Python solution for 2016/06")|[**7**](https://adventofcode.com/2016/day/7) [<img height=12 src=".assets/py.svg">](Python/2016/07.py "Python solution for 2016/07")|[**8**](https://adventofcode.com/2016/day/8) [<img height=12 src=".assets/py.svg">](Python/2016/08.py "Python solution for 2016/08")|[**9**](https://adventofcode.com/2016/day/9) [<img height=12 src=".assets/py.svg">](Python/2016/09.py "Python solution for 2016/09")|[**10**](https://adventofcode.com/2016/day/10) [<img height=12 src=".assets/py.svg">](Python/2016/10.py "Python solution for 2016/10")|[**11**](https://adventofcode.com/2016/day/11) [<img height=12 src=".assets/py.svg">](Python/2016/11.py "Python solution for 2016/11")|
|
||||
|[**12**](https://adventofcode.com/2016/day/12) [<img height=12 src=".assets/py.svg">](Python/2016/12.py "Python solution for 2016/12")|[**13**](https://adventofcode.com/2016/day/13) [<img height=12 src=".assets/py.svg">](Python/2016/13.py "Python solution for 2016/13")|[**14**](https://adventofcode.com/2016/day/14) [<img height=12 src=".assets/py.svg">](Python/2016/14.py "Python solution for 2016/14")|[**15**](https://adventofcode.com/2016/day/15) [<img height=12 src=".assets/py.svg">](Python/2016/15.py "Python solution for 2016/15")|[**16**](https://adventofcode.com/2016/day/16) [<img height=12 src=".assets/py.svg">](Python/2016/16.py "Python solution for 2016/16")|[**17**](https://adventofcode.com/2016/day/17) [<img height=12 src=".assets/py.svg">](Python/2016/17.py "Python solution for 2016/17")|[**18**](https://adventofcode.com/2016/day/18) [<img height=12 src=".assets/py.svg">](Python/2016/18.py "Python solution for 2016/18")|
|
||||
|[**19**](https://adventofcode.com/2016/day/19) [<img height=12 src=".assets/py.svg">](Python/2016/19.py "Python solution for 2016/19")|[**20**](https://adventofcode.com/2016/day/20) [<img height=12 src=".assets/py.svg">](Python/2016/20.py "Python solution for 2016/20")|[**21**](https://adventofcode.com/2016/day/21) [<img height=12 src=".assets/py.svg">](Python/2016/21.py "Python solution for 2016/21")|[**22**](https://adventofcode.com/2016/day/22) [<img height=12 src=".assets/py.svg">](Python/2016/22.py "Python solution for 2016/22")|[**23**](https://adventofcode.com/2016/day/23) [<img height=12 src=".assets/py.svg">](Python/2016/23.py "Python solution for 2016/23")|[**24**](https://adventofcode.com/2016/day/24) [<img height=12 src=".assets/py.svg">](Python/2016/24.py "Python solution for 2016/24")|[**25**](https://adventofcode.com/2016/day/25) [<img height=12 src=".assets/py.svg">](Python/2016/25.py "Python solution for 2016/25")|
|
||||
|26|27|28|29|30|31||
|
||||
|
||||
## [2015](https://adventofcode.com/2015) ([<img height=18 src=".assets/py.svg"> Python](Python/2015): 25/25)
|
||||
|Mo|Tu|We|Th|Fr|Sa|Su|
|
||||
|-|-|-|-|-|-|-|
|
||||
||[**1**](https://adventofcode.com/2015/day/1) [<img height=12 src=".assets/py.svg">](Python/2015/01.ipynb "Python solution for 2015/01")|[**2**](https://adventofcode.com/2015/day/2) [<img height=12 src=".assets/py.svg">](Python/2015/02.ipynb "Python solution for 2015/02")|[**3**](https://adventofcode.com/2015/day/3) [<img height=12 src=".assets/py.svg">](Python/2015/03.ipynb "Python solution for 2015/03")|[**4**](https://adventofcode.com/2015/day/4) [<img height=12 src=".assets/py.svg">](Python/2015/04.ipynb "Python solution for 2015/04")|[**5**](https://adventofcode.com/2015/day/5) [<img height=12 src=".assets/py.svg">](Python/2015/05.ipynb "Python solution for 2015/05")|[**6**](https://adventofcode.com/2015/day/6) [<img height=12 src=".assets/py.svg">](Python/2015/06.ipynb "Python solution for 2015/06")|
|
||||
|[**7**](https://adventofcode.com/2015/day/7) [<img height=12 src=".assets/py.svg">](Python/2015/07.ipynb "Python solution for 2015/07")|[**8**](https://adventofcode.com/2015/day/8) [<img height=12 src=".assets/py.svg">](Python/2015/08.ipynb "Python solution for 2015/08")|[**9**](https://adventofcode.com/2015/day/9) [<img height=12 src=".assets/py.svg">](Python/2015/09.ipynb "Python solution for 2015/09")|[**10**](https://adventofcode.com/2015/day/10) [<img height=12 src=".assets/py.svg">](Python/2015/10.ipynb "Python solution for 2015/10")|[**11**](https://adventofcode.com/2015/day/11) [<img height=12 src=".assets/py.svg">](Python/2015/11.ipynb "Python solution for 2015/11")|[**12**](https://adventofcode.com/2015/day/12) [<img height=12 src=".assets/py.svg">](Python/2015/12.ipynb "Python solution for 2015/12")|[**13**](https://adventofcode.com/2015/day/13) [<img height=12 src=".assets/py.svg">](Python/2015/13.ipynb "Python solution for 2015/13")|
|
||||
|[**14**](https://adventofcode.com/2015/day/14) [<img height=12 src=".assets/py.svg">](Python/2015/14.ipynb "Python solution for 2015/14")|[**15**](https://adventofcode.com/2015/day/15) [<img height=12 src=".assets/py.svg">](Python/2015/15.ipynb "Python solution for 2015/15")|[**16**](https://adventofcode.com/2015/day/16) [<img height=12 src=".assets/py.svg">](Python/2015/16.ipynb "Python solution for 2015/16")|[**17**](https://adventofcode.com/2015/day/17) [<img height=12 src=".assets/py.svg">](Python/2015/17.ipynb "Python solution for 2015/17")|[**18**](https://adventofcode.com/2015/day/18) [<img height=12 src=".assets/py.svg">](Python/2015/18.ipynb "Python solution for 2015/18")|[**19**](https://adventofcode.com/2015/day/19) [<img height=12 src=".assets/py.svg">](Python/2015/19.ipynb "Python solution for 2015/19")|[**20**](https://adventofcode.com/2015/day/20) [<img height=12 src=".assets/py.svg">](Python/2015/20.ipynb "Python solution for 2015/20")|
|
||||
|[**21**](https://adventofcode.com/2015/day/21) [<img height=12 src=".assets/py.svg">](Python/2015/21.ipynb "Python solution for 2015/21")|[**22**](https://adventofcode.com/2015/day/22) [<img height=12 src=".assets/py.svg">](Python/2015/22.ipynb "Python solution for 2015/22")|[**23**](https://adventofcode.com/2015/day/23) [<img height=12 src=".assets/py.svg">](Python/2015/23.ipynb "Python solution for 2015/23")|[**24**](https://adventofcode.com/2015/day/24) [<img height=12 src=".assets/py.svg">](Python/2015/24.ipynb "Python solution for 2015/24")|[**25**](https://adventofcode.com/2015/day/25) [<img height=12 src=".assets/py.svg">](Python/2015/25.ipynb "Python solution for 2015/25")|26|27|
|
||||
||[**1**](https://adventofcode.com/2015/day/1) [<img height=12 src=".assets/py.svg">](Python/2015/01.py "Python solution for 2015/01")|[**2**](https://adventofcode.com/2015/day/2) [<img height=12 src=".assets/py.svg">](Python/2015/02.py "Python solution for 2015/02")|[**3**](https://adventofcode.com/2015/day/3) [<img height=12 src=".assets/py.svg">](Python/2015/03.py "Python solution for 2015/03")|[**4**](https://adventofcode.com/2015/day/4) [<img height=12 src=".assets/py.svg">](Python/2015/04.py "Python solution for 2015/04")|[**5**](https://adventofcode.com/2015/day/5) [<img height=12 src=".assets/py.svg">](Python/2015/05.py "Python solution for 2015/05")|[**6**](https://adventofcode.com/2015/day/6) [<img height=12 src=".assets/py.svg">](Python/2015/06.py "Python solution for 2015/06")|
|
||||
|[**7**](https://adventofcode.com/2015/day/7) [<img height=12 src=".assets/py.svg">](Python/2015/07.py "Python solution for 2015/07")|[**8**](https://adventofcode.com/2015/day/8) [<img height=12 src=".assets/py.svg">](Python/2015/08.py "Python solution for 2015/08")|[**9**](https://adventofcode.com/2015/day/9) [<img height=12 src=".assets/py.svg">](Python/2015/09.py "Python solution for 2015/09")|[**10**](https://adventofcode.com/2015/day/10) [<img height=12 src=".assets/py.svg">](Python/2015/10.py "Python solution for 2015/10")|[**11**](https://adventofcode.com/2015/day/11) [<img height=12 src=".assets/py.svg">](Python/2015/11.py "Python solution for 2015/11")|[**12**](https://adventofcode.com/2015/day/12) [<img height=12 src=".assets/py.svg">](Python/2015/12.py "Python solution for 2015/12")|[**13**](https://adventofcode.com/2015/day/13) [<img height=12 src=".assets/py.svg">](Python/2015/13.py "Python solution for 2015/13")|
|
||||
|[**14**](https://adventofcode.com/2015/day/14) [<img height=12 src=".assets/py.svg">](Python/2015/14.py "Python solution for 2015/14")|[**15**](https://adventofcode.com/2015/day/15) [<img height=12 src=".assets/py.svg">](Python/2015/15.py "Python solution for 2015/15")|[**16**](https://adventofcode.com/2015/day/16) [<img height=12 src=".assets/py.svg">](Python/2015/16.py "Python solution for 2015/16")|[**17**](https://adventofcode.com/2015/day/17) [<img height=12 src=".assets/py.svg">](Python/2015/17.py "Python solution for 2015/17")|[**18**](https://adventofcode.com/2015/day/18) [<img height=12 src=".assets/py.svg">](Python/2015/18.py "Python solution for 2015/18")|[**19**](https://adventofcode.com/2015/day/19) [<img height=12 src=".assets/py.svg">](Python/2015/19.py "Python solution for 2015/19")|[**20**](https://adventofcode.com/2015/day/20) [<img height=12 src=".assets/py.svg">](Python/2015/20.py "Python solution for 2015/20")|
|
||||
|[**21**](https://adventofcode.com/2015/day/21) [<img height=12 src=".assets/py.svg">](Python/2015/21.py "Python solution for 2015/21")|[**22**](https://adventofcode.com/2015/day/22) [<img height=12 src=".assets/py.svg">](Python/2015/22.py "Python solution for 2015/22")|[**23**](https://adventofcode.com/2015/day/23) [<img height=12 src=".assets/py.svg">](Python/2015/23.py "Python solution for 2015/23")|[**24**](https://adventofcode.com/2015/day/24) [<img height=12 src=".assets/py.svg">](Python/2015/24.py "Python solution for 2015/24")|[**25**](https://adventofcode.com/2015/day/25) [<img height=12 src=".assets/py.svg">](Python/2015/25.py "Python solution for 2015/25")|26|27|
|
||||
|28|29|30|31||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue