Compare commits
No commits in common. "2024/rust" and "main" have entirely different histories.
58 changed files with 151778 additions and 4356 deletions
2
.envrc
2
.envrc
|
@ -1,2 +0,0 @@
|
||||||
dotenv
|
|
||||||
use flake
|
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,5 +1,2 @@
|
||||||
/target
|
node_modules/
|
||||||
/result
|
yarn-*.cjs
|
||||||
/result-lib
|
|
||||||
.direnv
|
|
||||||
.env
|
|
8
AdventOfCode.code-workspace
Normal file
8
AdventOfCode.code-workspace
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
1469
Cargo.lock
generated
1469
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
53
Cargo.toml
53
Cargo.toml
|
@ -1,53 +0,0 @@
|
||||||
[package]
|
|
||||||
authors = ["Toby <toby@tobot.dev>"]
|
|
||||||
name = "advent-of-code-2024"
|
|
||||||
version = "24.4.2"
|
|
||||||
edition = "2021"
|
|
||||||
default-run = "get_input"
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
strip = "symbols"
|
|
||||||
lto = true
|
|
||||||
opt-level = 3
|
|
||||||
codegen-units = 1
|
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
|
||||||
opt-level = 3
|
|
||||||
codegen-units = 1
|
|
||||||
[profile.release.package."*"]
|
|
||||||
opt-level = 3
|
|
||||||
codegen-units = 1
|
|
||||||
[profile.release.build-override]
|
|
||||||
codegen-units = 1
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "get_input"
|
|
||||||
path = "src/get_input.rs"
|
|
||||||
test = false
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "template"
|
|
||||||
# day00 for alphabetic sorting
|
|
||||||
path = "day00/main.rs"
|
|
||||||
test = false
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "day01"
|
|
||||||
path = "day01/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "day02"
|
|
||||||
path = "day02/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "day03"
|
|
||||||
path = "day03/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "day04"
|
|
||||||
path = "day04/main.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
regex-lite = "0.1.6"
|
|
||||||
reqwest = { version = "0.12.9", features = ["blocking"] }
|
|
||||||
|
|
21
LICENSE
21
LICENSE
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 Tobias Berger
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
1
Python/day1/input
Normal file
1
Python/day1/input
Normal file
File diff suppressed because one or more lines are too long
132
Python/day1/solution.ipynb
Normal file
132
Python/day1/solution.ipynb
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"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-final"
|
||||||
|
},
|
||||||
|
"orig_nbformat": 2,
|
||||||
|
"kernelspec": {
|
||||||
|
"name": "python3",
|
||||||
|
"display_name": "Python 3.8.6 64-bit",
|
||||||
|
"metadata": {
|
||||||
|
"interpreter": {
|
||||||
|
"hash": "1ddf53fa84779e14f0db18342168679c9c165a81c5f324dac828befab228d68d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2,
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Get puzzle input from input file\n",
|
||||||
|
"\n",
|
||||||
|
"puzzle_input = open(\"input\").read()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 1 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 11,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"ups = puzzle_input.count(\"(\")\n",
|
||||||
|
"downs = puzzle_input.count(\")\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"end_floor = ups - downs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"print(end_floor)"
|
||||||
|
],
|
||||||
|
"cell_type": "code",
|
||||||
|
"metadata": {},
|
||||||
|
"execution_count": 13,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"138\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 2 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 14,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"current_floor = 0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 15,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"index = 0\n",
|
||||||
|
"while current_floor >= 0 and index < len(puzzle_input):\n",
|
||||||
|
" if puzzle_input[index] == \"(\":\n",
|
||||||
|
" current_floor += 1\n",
|
||||||
|
" elif puzzle_input[index] == \")\":\n",
|
||||||
|
" current_floor -= 1\n",
|
||||||
|
" index += 1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 16,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"1771\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"print(index)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1000
Python/day2/input
Normal file
1000
Python/day2/input
Normal file
File diff suppressed because it is too large
Load diff
104
Python/day2/solution.ipynb
Normal file
104
Python/day2/solution.ipynb
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"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-final"
|
||||||
|
},
|
||||||
|
"orig_nbformat": 2,
|
||||||
|
"kernelspec": {
|
||||||
|
"name": "python3",
|
||||||
|
"display_name": "Python 3.8.6 64-bit",
|
||||||
|
"metadata": {
|
||||||
|
"interpreter": {
|
||||||
|
"hash": "1ddf53fa84779e14f0db18342168679c9c165a81c5f324dac828befab228d68d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2,
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Get puzzle input from input file\n",
|
||||||
|
"\n",
|
||||||
|
"puzzle_input = open(\"input\").read().split(\"\\n\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 1 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"1606483\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"wrapping_paper = 0\n",
|
||||||
|
"for packet in puzzle_input:\n",
|
||||||
|
" l, w, h = map(lambda val: int(val), packet.split(\"x\"))\n",
|
||||||
|
" # the surface area of the box, which is 2*l*w + 2*w*h + 2*h*l\n",
|
||||||
|
" sides = [l*w*2, w*h*2, l*h*2]\n",
|
||||||
|
" # extra paper for each present: the area of the smallest side.\n",
|
||||||
|
" wrapping_paper += sum(sides) + int(min(sides)/2)\n",
|
||||||
|
"print(wrapping_paper)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 2 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"3842356\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"ribbon = 0\n",
|
||||||
|
"for packet in puzzle_input:\n",
|
||||||
|
" l, w, h = map(lambda val: int(val), packet.split(\"x\"))\n",
|
||||||
|
" # the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of the present\n",
|
||||||
|
" ribbon += l*w*h\n",
|
||||||
|
" # The ribbon required to wrap a present is the shortest distance around its sides, or the smallest perimeter of any one face\n",
|
||||||
|
" x, y = sorted([l, w, h])[0:2]\n",
|
||||||
|
" ribbon += 2*x + 2*y\n",
|
||||||
|
"print(ribbon)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
Python/day3/input
Normal file
1
Python/day3/input
Normal file
File diff suppressed because one or more lines are too long
123
Python/day3/solution.ipynb
Normal file
123
Python/day3/solution.ipynb
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"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-final"
|
||||||
|
},
|
||||||
|
"orig_nbformat": 2,
|
||||||
|
"kernelspec": {
|
||||||
|
"name": "python3",
|
||||||
|
"display_name": "Python 3.8.6 64-bit",
|
||||||
|
"metadata": {
|
||||||
|
"interpreter": {
|
||||||
|
"hash": "1ddf53fa84779e14f0db18342168679c9c165a81c5f324dac828befab228d68d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2,
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Get puzzle input from input file\n",
|
||||||
|
"\n",
|
||||||
|
"puzzle_input = open(\"input\").read()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 1 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"2572\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"delivered = {(0,0)}\n",
|
||||||
|
"\n",
|
||||||
|
"x, y = 0, 0\n",
|
||||||
|
"ops = {\n",
|
||||||
|
" \"^\": [+0, +1],\n",
|
||||||
|
" \"v\": [-0, -1],\n",
|
||||||
|
" \"<\": [-1, -0],\n",
|
||||||
|
" \">\": [+1, +0]\n",
|
||||||
|
"}\n",
|
||||||
|
"for char in puzzle_input:\n",
|
||||||
|
" dx, dy = ops[char]\n",
|
||||||
|
" x += dx\n",
|
||||||
|
" y += dy\n",
|
||||||
|
" delivered.add((x, y))\n",
|
||||||
|
"print(len(delivered))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 2 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"2631\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"delivered = {(0,0)}\n",
|
||||||
|
"\n",
|
||||||
|
"santa = (0, 0)\n",
|
||||||
|
"robo_santa = (0, 0)\n",
|
||||||
|
"ops = {\n",
|
||||||
|
" \"^\": [+0, +1],\n",
|
||||||
|
" \"v\": [-0, -1],\n",
|
||||||
|
" \"<\": [-1, -0],\n",
|
||||||
|
" \">\": [+1, +0]\n",
|
||||||
|
"}\n",
|
||||||
|
"robot = False\n",
|
||||||
|
"for char in puzzle_input:\n",
|
||||||
|
" dx, dy = ops[char]\n",
|
||||||
|
" if robot:\n",
|
||||||
|
" robo_santa = (robo_santa[0]+dx, robo_santa[1]+dy)\n",
|
||||||
|
" delivered.add(robo_santa)\n",
|
||||||
|
" else:\n",
|
||||||
|
" santa = (santa[0]+dx, santa[1]+dy)\n",
|
||||||
|
" delivered.add(santa)\n",
|
||||||
|
" robot = not robot\n",
|
||||||
|
"print(len(delivered))"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
Python/day4/input
Normal file
1
Python/day4/input
Normal file
|
@ -0,0 +1 @@
|
||||||
|
yzbqklnj
|
112
Python/day4/solution.ipynb
Normal file
112
Python/day4/solution.ipynb
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"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-final"
|
||||||
|
},
|
||||||
|
"orig_nbformat": 2,
|
||||||
|
"kernelspec": {
|
||||||
|
"name": "python3",
|
||||||
|
"display_name": "Python 3.8.6 64-bit",
|
||||||
|
"metadata": {
|
||||||
|
"interpreter": {
|
||||||
|
"hash": "1ddf53fa84779e14f0db18342168679c9c165a81c5f324dac828befab228d68d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2,
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import hashlib"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Get puzzle input from input file\n",
|
||||||
|
"\n",
|
||||||
|
"puzzle_input = open(\"input\").read()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 1 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 16,
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"282749\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"current_hash = \"\"\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"while not current_hash[0:5] == \"00000\":\n",
|
||||||
|
" i += 1\n",
|
||||||
|
" md5 = hashlib.md5(f\"{puzzle_input}{i}\".encode(\"utf-8\"))\n",
|
||||||
|
" current_hash = md5.hexdigest()\n",
|
||||||
|
"print(i)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 2 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 17,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": [
|
||||||
|
"9962624\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"current_hash = \"\"\n",
|
||||||
|
"i = 0\n",
|
||||||
|
"while not current_hash[0:6] == \"000000\":\n",
|
||||||
|
" i += 1\n",
|
||||||
|
" md5 = hashlib.md5(f\"{puzzle_input}{i}\".encode(\"utf-8\"))\n",
|
||||||
|
" current_hash = md5.hexdigest()\n",
|
||||||
|
"print(i)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1000
Python/day5/input
Normal file
1000
Python/day5/input
Normal file
File diff suppressed because it is too large
Load diff
119
Python/day5/solution.ipynb
Normal file
119
Python/day5/solution.ipynb
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import re"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Get puzzle input from input file\n",
|
||||||
|
"\n",
|
||||||
|
"puzzle_input = open(\"input\").read().split(\"\\n\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Part 1 #"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"238\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"double_letter_test = re.compile(r\"(.)\\1\", re.IGNORECASE)\n",
|
||||||
|
"unnice_test = re.compile(r\"ab|cd|pq|xy\", re.IGNORECASE)\n",
|
||||||
|
"\n",
|
||||||
|
"def filter_function_part_one(line: str) -> bool:\n",
|
||||||
|
" return (sum(map(line.lower().count, \"aeiou\")) >= 3) and bool(not unnice_test.search(line)) and bool(double_letter_test.search(line))\n",
|
||||||
|
"\n",
|
||||||
|
"filtered_lines = list(filter(\n",
|
||||||
|
" filter_function_part_one,\n",
|
||||||
|
" puzzle_input\n",
|
||||||
|
"))\n",
|
||||||
|
"print(len(filtered_lines))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Part 2 #"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"69\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"def filter_function_part_two(line: str) -> bool:\n",
|
||||||
|
" return re.findall(r\"(..).*\\1\", line) and re.findall(r\"(.).\\1\", line)\n",
|
||||||
|
"\n",
|
||||||
|
"filtered_lines = filter(\n",
|
||||||
|
" filter_function_part_two,\n",
|
||||||
|
" puzzle_input\n",
|
||||||
|
")\n",
|
||||||
|
"print(len(list(filtered_lines)))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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
|
||||||
|
}
|
300
Python/day6/input
Normal file
300
Python/day6/input
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
turn off 660,55 through 986,197
|
||||||
|
turn off 341,304 through 638,850
|
||||||
|
turn off 199,133 through 461,193
|
||||||
|
toggle 322,558 through 977,958
|
||||||
|
toggle 537,781 through 687,941
|
||||||
|
turn on 226,196 through 599,390
|
||||||
|
turn on 240,129 through 703,297
|
||||||
|
turn on 317,329 through 451,798
|
||||||
|
turn on 957,736 through 977,890
|
||||||
|
turn on 263,530 through 559,664
|
||||||
|
turn on 158,270 through 243,802
|
||||||
|
toggle 223,39 through 454,511
|
||||||
|
toggle 544,218 through 979,872
|
||||||
|
turn on 313,306 through 363,621
|
||||||
|
toggle 173,401 through 496,407
|
||||||
|
toggle 333,60 through 748,159
|
||||||
|
turn off 87,577 through 484,608
|
||||||
|
turn on 809,648 through 826,999
|
||||||
|
toggle 352,432 through 628,550
|
||||||
|
turn off 197,408 through 579,569
|
||||||
|
turn off 1,629 through 802,633
|
||||||
|
turn off 61,44 through 567,111
|
||||||
|
toggle 880,25 through 903,973
|
||||||
|
turn on 347,123 through 864,746
|
||||||
|
toggle 728,877 through 996,975
|
||||||
|
turn on 121,895 through 349,906
|
||||||
|
turn on 888,547 through 931,628
|
||||||
|
toggle 398,782 through 834,882
|
||||||
|
turn on 966,850 through 989,953
|
||||||
|
turn off 891,543 through 914,991
|
||||||
|
toggle 908,77 through 916,117
|
||||||
|
turn on 576,900 through 943,934
|
||||||
|
turn off 580,170 through 963,206
|
||||||
|
turn on 184,638 through 192,944
|
||||||
|
toggle 940,147 through 978,730
|
||||||
|
turn off 854,56 through 965,591
|
||||||
|
toggle 717,172 through 947,995
|
||||||
|
toggle 426,987 through 705,998
|
||||||
|
turn on 987,157 through 992,278
|
||||||
|
toggle 995,774 through 997,784
|
||||||
|
turn off 796,96 through 845,182
|
||||||
|
turn off 451,87 through 711,655
|
||||||
|
turn off 380,93 through 968,676
|
||||||
|
turn on 263,468 through 343,534
|
||||||
|
turn on 917,936 through 928,959
|
||||||
|
toggle 478,7 through 573,148
|
||||||
|
turn off 428,339 through 603,624
|
||||||
|
turn off 400,880 through 914,953
|
||||||
|
toggle 679,428 through 752,779
|
||||||
|
turn off 697,981 through 709,986
|
||||||
|
toggle 482,566 through 505,725
|
||||||
|
turn off 956,368 through 993,516
|
||||||
|
toggle 735,823 through 783,883
|
||||||
|
turn off 48,487 through 892,496
|
||||||
|
turn off 116,680 through 564,819
|
||||||
|
turn on 633,865 through 729,930
|
||||||
|
turn off 314,618 through 571,922
|
||||||
|
toggle 138,166 through 936,266
|
||||||
|
turn on 444,732 through 664,960
|
||||||
|
turn off 109,337 through 972,497
|
||||||
|
turn off 51,432 through 77,996
|
||||||
|
turn off 259,297 through 366,744
|
||||||
|
toggle 801,130 through 917,544
|
||||||
|
toggle 767,982 through 847,996
|
||||||
|
turn on 216,507 through 863,885
|
||||||
|
turn off 61,441 through 465,731
|
||||||
|
turn on 849,970 through 944,987
|
||||||
|
toggle 845,76 through 852,951
|
||||||
|
toggle 732,615 through 851,936
|
||||||
|
toggle 251,128 through 454,778
|
||||||
|
turn on 324,429 through 352,539
|
||||||
|
toggle 52,450 through 932,863
|
||||||
|
turn off 449,379 through 789,490
|
||||||
|
turn on 317,319 through 936,449
|
||||||
|
toggle 887,670 through 957,838
|
||||||
|
toggle 671,613 through 856,664
|
||||||
|
turn off 186,648 through 985,991
|
||||||
|
turn off 471,689 through 731,717
|
||||||
|
toggle 91,331 through 750,758
|
||||||
|
toggle 201,73 through 956,524
|
||||||
|
toggle 82,614 through 520,686
|
||||||
|
toggle 84,287 through 467,734
|
||||||
|
turn off 132,367 through 208,838
|
||||||
|
toggle 558,684 through 663,920
|
||||||
|
turn on 237,952 through 265,997
|
||||||
|
turn on 694,713 through 714,754
|
||||||
|
turn on 632,523 through 862,827
|
||||||
|
turn on 918,780 through 948,916
|
||||||
|
turn on 349,586 through 663,976
|
||||||
|
toggle 231,29 through 257,589
|
||||||
|
toggle 886,428 through 902,993
|
||||||
|
turn on 106,353 through 236,374
|
||||||
|
turn on 734,577 through 759,684
|
||||||
|
turn off 347,843 through 696,912
|
||||||
|
turn on 286,699 through 964,883
|
||||||
|
turn on 605,875 through 960,987
|
||||||
|
turn off 328,286 through 869,461
|
||||||
|
turn off 472,569 through 980,848
|
||||||
|
toggle 673,573 through 702,884
|
||||||
|
turn off 398,284 through 738,332
|
||||||
|
turn on 158,50 through 284,411
|
||||||
|
turn off 390,284 through 585,663
|
||||||
|
turn on 156,579 through 646,581
|
||||||
|
turn on 875,493 through 989,980
|
||||||
|
toggle 486,391 through 924,539
|
||||||
|
turn on 236,722 through 272,964
|
||||||
|
toggle 228,282 through 470,581
|
||||||
|
toggle 584,389 through 750,761
|
||||||
|
turn off 899,516 through 900,925
|
||||||
|
turn on 105,229 through 822,846
|
||||||
|
turn off 253,77 through 371,877
|
||||||
|
turn on 826,987 through 906,992
|
||||||
|
turn off 13,152 through 615,931
|
||||||
|
turn on 835,320 through 942,399
|
||||||
|
turn on 463,504 through 536,720
|
||||||
|
toggle 746,942 through 786,998
|
||||||
|
turn off 867,333 through 965,403
|
||||||
|
turn on 591,477 through 743,692
|
||||||
|
turn off 403,437 through 508,908
|
||||||
|
turn on 26,723 through 368,814
|
||||||
|
turn on 409,485 through 799,809
|
||||||
|
turn on 115,630 through 704,705
|
||||||
|
turn off 228,183 through 317,220
|
||||||
|
toggle 300,649 through 382,842
|
||||||
|
turn off 495,365 through 745,562
|
||||||
|
turn on 698,346 through 744,873
|
||||||
|
turn on 822,932 through 951,934
|
||||||
|
toggle 805,30 through 925,421
|
||||||
|
toggle 441,152 through 653,274
|
||||||
|
toggle 160,81 through 257,587
|
||||||
|
turn off 350,781 through 532,917
|
||||||
|
toggle 40,583 through 348,636
|
||||||
|
turn on 280,306 through 483,395
|
||||||
|
toggle 392,936 through 880,955
|
||||||
|
toggle 496,591 through 851,934
|
||||||
|
turn off 780,887 through 946,994
|
||||||
|
turn off 205,735 through 281,863
|
||||||
|
toggle 100,876 through 937,915
|
||||||
|
turn on 392,393 through 702,878
|
||||||
|
turn on 956,374 through 976,636
|
||||||
|
toggle 478,262 through 894,775
|
||||||
|
turn off 279,65 through 451,677
|
||||||
|
turn on 397,541 through 809,847
|
||||||
|
turn on 444,291 through 451,586
|
||||||
|
toggle 721,408 through 861,598
|
||||||
|
turn on 275,365 through 609,382
|
||||||
|
turn on 736,24 through 839,72
|
||||||
|
turn off 86,492 through 582,712
|
||||||
|
turn on 676,676 through 709,703
|
||||||
|
turn off 105,710 through 374,817
|
||||||
|
toggle 328,748 through 845,757
|
||||||
|
toggle 335,79 through 394,326
|
||||||
|
toggle 193,157 through 633,885
|
||||||
|
turn on 227,48 through 769,743
|
||||||
|
toggle 148,333 through 614,568
|
||||||
|
toggle 22,30 through 436,263
|
||||||
|
toggle 547,447 through 688,969
|
||||||
|
toggle 576,621 through 987,740
|
||||||
|
turn on 711,334 through 799,515
|
||||||
|
turn on 541,448 through 654,951
|
||||||
|
toggle 792,199 through 798,990
|
||||||
|
turn on 89,956 through 609,960
|
||||||
|
toggle 724,433 through 929,630
|
||||||
|
toggle 144,895 through 201,916
|
||||||
|
toggle 226,730 through 632,871
|
||||||
|
turn off 760,819 through 828,974
|
||||||
|
toggle 887,180 through 940,310
|
||||||
|
toggle 222,327 through 805,590
|
||||||
|
turn off 630,824 through 885,963
|
||||||
|
turn on 940,740 through 954,946
|
||||||
|
turn on 193,373 through 779,515
|
||||||
|
toggle 304,955 through 469,975
|
||||||
|
turn off 405,480 through 546,960
|
||||||
|
turn on 662,123 through 690,669
|
||||||
|
turn off 615,238 through 750,714
|
||||||
|
turn on 423,220 through 930,353
|
||||||
|
turn on 329,769 through 358,970
|
||||||
|
toggle 590,151 through 704,722
|
||||||
|
turn off 884,539 through 894,671
|
||||||
|
toggle 449,241 through 984,549
|
||||||
|
toggle 449,260 through 496,464
|
||||||
|
turn off 306,448 through 602,924
|
||||||
|
turn on 286,805 through 555,901
|
||||||
|
toggle 722,177 through 922,298
|
||||||
|
toggle 491,554 through 723,753
|
||||||
|
turn on 80,849 through 174,996
|
||||||
|
turn off 296,561 through 530,856
|
||||||
|
toggle 653,10 through 972,284
|
||||||
|
toggle 529,236 through 672,614
|
||||||
|
toggle 791,598 through 989,695
|
||||||
|
turn on 19,45 through 575,757
|
||||||
|
toggle 111,55 through 880,871
|
||||||
|
turn off 197,897 through 943,982
|
||||||
|
turn on 912,336 through 977,605
|
||||||
|
toggle 101,221 through 537,450
|
||||||
|
turn on 101,104 through 969,447
|
||||||
|
toggle 71,527 through 587,717
|
||||||
|
toggle 336,445 through 593,889
|
||||||
|
toggle 214,179 through 575,699
|
||||||
|
turn on 86,313 through 96,674
|
||||||
|
toggle 566,427 through 906,888
|
||||||
|
turn off 641,597 through 850,845
|
||||||
|
turn on 606,524 through 883,704
|
||||||
|
turn on 835,775 through 867,887
|
||||||
|
toggle 547,301 through 897,515
|
||||||
|
toggle 289,930 through 413,979
|
||||||
|
turn on 361,122 through 457,226
|
||||||
|
turn on 162,187 through 374,746
|
||||||
|
turn on 348,461 through 454,675
|
||||||
|
turn off 966,532 through 985,537
|
||||||
|
turn on 172,354 through 630,606
|
||||||
|
turn off 501,880 through 680,993
|
||||||
|
turn off 8,70 through 566,592
|
||||||
|
toggle 433,73 through 690,651
|
||||||
|
toggle 840,798 through 902,971
|
||||||
|
toggle 822,204 through 893,760
|
||||||
|
turn off 453,496 through 649,795
|
||||||
|
turn off 969,549 through 990,942
|
||||||
|
turn off 789,28 through 930,267
|
||||||
|
toggle 880,98 through 932,434
|
||||||
|
toggle 568,674 through 669,753
|
||||||
|
turn on 686,228 through 903,271
|
||||||
|
turn on 263,995 through 478,999
|
||||||
|
toggle 534,675 through 687,955
|
||||||
|
turn off 342,434 through 592,986
|
||||||
|
toggle 404,768 through 677,867
|
||||||
|
toggle 126,723 through 978,987
|
||||||
|
toggle 749,675 through 978,959
|
||||||
|
turn off 445,330 through 446,885
|
||||||
|
turn off 463,205 through 924,815
|
||||||
|
turn off 417,430 through 915,472
|
||||||
|
turn on 544,990 through 912,999
|
||||||
|
turn off 201,255 through 834,789
|
||||||
|
turn off 261,142 through 537,862
|
||||||
|
turn off 562,934 through 832,984
|
||||||
|
turn off 459,978 through 691,980
|
||||||
|
turn off 73,911 through 971,972
|
||||||
|
turn on 560,448 through 723,810
|
||||||
|
turn on 204,630 through 217,854
|
||||||
|
turn off 91,259 through 611,607
|
||||||
|
turn on 877,32 through 978,815
|
||||||
|
turn off 950,438 through 974,746
|
||||||
|
toggle 426,30 through 609,917
|
||||||
|
toggle 696,37 through 859,201
|
||||||
|
toggle 242,417 through 682,572
|
||||||
|
turn off 388,401 through 979,528
|
||||||
|
turn off 79,345 through 848,685
|
||||||
|
turn off 98,91 through 800,434
|
||||||
|
toggle 650,700 through 972,843
|
||||||
|
turn off 530,450 through 538,926
|
||||||
|
turn on 428,559 through 962,909
|
||||||
|
turn on 78,138 through 92,940
|
||||||
|
toggle 194,117 through 867,157
|
||||||
|
toggle 785,355 through 860,617
|
||||||
|
turn off 379,441 through 935,708
|
||||||
|
turn off 605,133 through 644,911
|
||||||
|
toggle 10,963 through 484,975
|
||||||
|
turn off 359,988 through 525,991
|
||||||
|
turn off 509,138 through 787,411
|
||||||
|
toggle 556,467 through 562,773
|
||||||
|
turn on 119,486 through 246,900
|
||||||
|
turn on 445,561 through 794,673
|
||||||
|
turn off 598,681 through 978,921
|
||||||
|
turn off 974,230 through 995,641
|
||||||
|
turn off 760,75 through 800,275
|
||||||
|
toggle 441,215 through 528,680
|
||||||
|
turn off 701,636 through 928,877
|
||||||
|
turn on 165,753 through 202,780
|
||||||
|
toggle 501,412 through 998,516
|
||||||
|
toggle 161,105 through 657,395
|
||||||
|
turn on 113,340 through 472,972
|
||||||
|
toggle 384,994 through 663,999
|
||||||
|
turn on 969,994 through 983,997
|
||||||
|
turn on 519,600 through 750,615
|
||||||
|
turn off 363,899 through 948,935
|
||||||
|
turn on 271,845 through 454,882
|
||||||
|
turn off 376,528 through 779,640
|
||||||
|
toggle 767,98 through 854,853
|
||||||
|
toggle 107,322 through 378,688
|
||||||
|
turn off 235,899 through 818,932
|
||||||
|
turn on 445,611 through 532,705
|
||||||
|
toggle 629,387 through 814,577
|
||||||
|
toggle 112,414 through 387,421
|
||||||
|
toggle 319,184 through 382,203
|
||||||
|
turn on 627,796 through 973,940
|
||||||
|
toggle 602,45 through 763,151
|
||||||
|
turn off 441,375 through 974,545
|
||||||
|
toggle 871,952 through 989,998
|
||||||
|
turn on 717,272 through 850,817
|
||||||
|
toggle 475,711 through 921,882
|
||||||
|
toggle 66,191 through 757,481
|
||||||
|
turn off 50,197 through 733,656
|
||||||
|
toggle 83,575 through 915,728
|
||||||
|
turn on 777,812 through 837,912
|
||||||
|
turn on 20,984 through 571,994
|
||||||
|
turn off 446,432 through 458,648
|
||||||
|
turn on 715,871 through 722,890
|
||||||
|
toggle 424,675 through 740,862
|
||||||
|
toggle 580,592 through 671,900
|
||||||
|
toggle 296,687 through 906,775
|
152
Python/day6/solution.ipynb
Normal file
152
Python/day6/solution.ipynb
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import re"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Get puzzle input from input file\n",
|
||||||
|
"\n",
|
||||||
|
"puzzle_input = open(\"input\").read()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def toggle(val: bool) -> bool:\n",
|
||||||
|
" return not val\n",
|
||||||
|
"\n",
|
||||||
|
"def turn_off(val: bool) -> bool:\n",
|
||||||
|
" return False\n",
|
||||||
|
"\n",
|
||||||
|
"def turn_on(val: bool) -> bool:\n",
|
||||||
|
" return True"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Part 1 #"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"400410\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"lights = [[False]*1000 for i in range(1000)]\n",
|
||||||
|
"for command in puzzle_input.split(\"\\n\"):\n",
|
||||||
|
" if re.search(\"toggle\", command):\n",
|
||||||
|
" method = toggle\n",
|
||||||
|
" elif re.search(\"on\", command):\n",
|
||||||
|
" method = turn_on\n",
|
||||||
|
" else:\n",
|
||||||
|
" method = turn_off\n",
|
||||||
|
" \n",
|
||||||
|
" points = re.search(r\"(\\d+,\\d+) through (\\d+,\\d+)\", command)\n",
|
||||||
|
" point_a = tuple(map(int, points.group(1).split(\",\")))\n",
|
||||||
|
" point_b = tuple(map(int, points.group(2).split(\",\")))\n",
|
||||||
|
" \n",
|
||||||
|
" for a in range(point_a[0], point_b[0]+1):\n",
|
||||||
|
" for b in range(point_a[1], point_b[1]+1):\n",
|
||||||
|
" lights[a][b] = method(lights[a][b])\n",
|
||||||
|
"\n",
|
||||||
|
"print(list(item for sublist in lights for item in sublist).count(True))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Part 2 #"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"15343601\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"def toggle(val: bool) -> bool:\n",
|
||||||
|
" return val+2\n",
|
||||||
|
"\n",
|
||||||
|
"def turn_off(val: bool) -> bool:\n",
|
||||||
|
" return max(val-1, 0)\n",
|
||||||
|
"\n",
|
||||||
|
"def turn_on(val: bool) -> bool:\n",
|
||||||
|
" return val+1\n",
|
||||||
|
"\n",
|
||||||
|
"lights = [[0]*1000 for i in range(1000)]\n",
|
||||||
|
"for command in puzzle_input.split(\"\\n\"):\n",
|
||||||
|
" if re.search(\"toggle\", command):\n",
|
||||||
|
" method = toggle\n",
|
||||||
|
" elif re.search(\"on\", command):\n",
|
||||||
|
" method = turn_on\n",
|
||||||
|
" else:\n",
|
||||||
|
" method = turn_off\n",
|
||||||
|
" \n",
|
||||||
|
" points = re.search(r\"(\\d+,\\d+) through (\\d+,\\d+)\", command)\n",
|
||||||
|
" point_a = tuple(map(int, points.group(1).split(\",\")))\n",
|
||||||
|
" point_b = tuple(map(int, points.group(2).split(\",\")))\n",
|
||||||
|
" \n",
|
||||||
|
" for a in range(point_a[0], point_b[0]+1):\n",
|
||||||
|
" for b in range(point_a[1], point_b[1]+1):\n",
|
||||||
|
" lights[a][b] = method(lights[a][b])\n",
|
||||||
|
"\n",
|
||||||
|
"print(sum(list(item for sublist in lights for item in sublist)))"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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
|
||||||
|
}
|
0
Python/template/input
Normal file
0
Python/template/input
Normal file
55
Python/template/solution.ipynb
Normal file
55
Python/template/solution.ipynb
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"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-final"
|
||||||
|
},
|
||||||
|
"orig_nbformat": 2,
|
||||||
|
"kernelspec": {
|
||||||
|
"name": "python3",
|
||||||
|
"display_name": "Python 3.8.6 64-bit",
|
||||||
|
"metadata": {
|
||||||
|
"interpreter": {
|
||||||
|
"hash": "1ddf53fa84779e14f0db18342168679c9c165a81c5f324dac828befab228d68d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2,
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Get puzzle input from input file\n",
|
||||||
|
"\n",
|
||||||
|
"puzzle_input = open(\"input\").read()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 1 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": [
|
||||||
|
"# Part 2 #"
|
||||||
|
],
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
5
TypeScript/day7/.yarnrc
Normal file
5
TypeScript/day7/.yarnrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
yarn-path ".yarn/releases/yarn-1.22.10.cjs"
|
339
TypeScript/day7/input
Normal file
339
TypeScript/day7/input
Normal file
|
@ -0,0 +1,339 @@
|
||||||
|
bn RSHIFT 2 -> bo
|
||||||
|
lf RSHIFT 1 -> ly
|
||||||
|
fo RSHIFT 3 -> fq
|
||||||
|
cj OR cp -> cq
|
||||||
|
fo OR fz -> ga
|
||||||
|
t OR s -> u
|
||||||
|
lx -> a
|
||||||
|
NOT ax -> ay
|
||||||
|
he RSHIFT 2 -> hf
|
||||||
|
lf OR lq -> lr
|
||||||
|
lr AND lt -> lu
|
||||||
|
dy OR ej -> ek
|
||||||
|
1 AND cx -> cy
|
||||||
|
hb LSHIFT 1 -> hv
|
||||||
|
1 AND bh -> bi
|
||||||
|
ih AND ij -> ik
|
||||||
|
c LSHIFT 1 -> t
|
||||||
|
ea AND eb -> ed
|
||||||
|
km OR kn -> ko
|
||||||
|
NOT bw -> bx
|
||||||
|
ci OR ct -> cu
|
||||||
|
NOT p -> q
|
||||||
|
lw OR lv -> lx
|
||||||
|
NOT lo -> lp
|
||||||
|
fp OR fv -> fw
|
||||||
|
o AND q -> r
|
||||||
|
dh AND dj -> dk
|
||||||
|
ap LSHIFT 1 -> bj
|
||||||
|
bk LSHIFT 1 -> ce
|
||||||
|
NOT ii -> ij
|
||||||
|
gh OR gi -> gj
|
||||||
|
kk RSHIFT 1 -> ld
|
||||||
|
lc LSHIFT 1 -> lw
|
||||||
|
lb OR la -> lc
|
||||||
|
1 AND am -> an
|
||||||
|
gn AND gp -> gq
|
||||||
|
lf RSHIFT 3 -> lh
|
||||||
|
e OR f -> g
|
||||||
|
lg AND lm -> lo
|
||||||
|
ci RSHIFT 1 -> db
|
||||||
|
cf LSHIFT 1 -> cz
|
||||||
|
bn RSHIFT 1 -> cg
|
||||||
|
et AND fe -> fg
|
||||||
|
is OR it -> iu
|
||||||
|
kw AND ky -> kz
|
||||||
|
ck AND cl -> cn
|
||||||
|
bj OR bi -> bk
|
||||||
|
gj RSHIFT 1 -> hc
|
||||||
|
iu AND jf -> jh
|
||||||
|
NOT bs -> bt
|
||||||
|
kk OR kv -> kw
|
||||||
|
ks AND ku -> kv
|
||||||
|
hz OR ik -> il
|
||||||
|
b RSHIFT 1 -> v
|
||||||
|
iu RSHIFT 1 -> jn
|
||||||
|
fo RSHIFT 5 -> fr
|
||||||
|
be AND bg -> bh
|
||||||
|
ga AND gc -> gd
|
||||||
|
hf OR hl -> hm
|
||||||
|
ld OR le -> lf
|
||||||
|
as RSHIFT 5 -> av
|
||||||
|
fm OR fn -> fo
|
||||||
|
hm AND ho -> hp
|
||||||
|
lg OR lm -> ln
|
||||||
|
NOT kx -> ky
|
||||||
|
kk RSHIFT 3 -> km
|
||||||
|
ek AND em -> en
|
||||||
|
NOT ft -> fu
|
||||||
|
NOT jh -> ji
|
||||||
|
jn OR jo -> jp
|
||||||
|
gj AND gu -> gw
|
||||||
|
d AND j -> l
|
||||||
|
et RSHIFT 1 -> fm
|
||||||
|
jq OR jw -> jx
|
||||||
|
ep OR eo -> eq
|
||||||
|
lv LSHIFT 15 -> lz
|
||||||
|
NOT ey -> ez
|
||||||
|
jp RSHIFT 2 -> jq
|
||||||
|
eg AND ei -> ej
|
||||||
|
NOT dm -> dn
|
||||||
|
jp AND ka -> kc
|
||||||
|
as AND bd -> bf
|
||||||
|
fk OR fj -> fl
|
||||||
|
dw OR dx -> dy
|
||||||
|
lj AND ll -> lm
|
||||||
|
ec AND ee -> ef
|
||||||
|
fq AND fr -> ft
|
||||||
|
NOT kp -> kq
|
||||||
|
ki OR kj -> kk
|
||||||
|
cz OR cy -> da
|
||||||
|
as RSHIFT 3 -> au
|
||||||
|
an LSHIFT 15 -> ar
|
||||||
|
fj LSHIFT 15 -> fn
|
||||||
|
1 AND fi -> fj
|
||||||
|
he RSHIFT 1 -> hx
|
||||||
|
lf RSHIFT 2 -> lg
|
||||||
|
kf LSHIFT 15 -> kj
|
||||||
|
dz AND ef -> eh
|
||||||
|
ib OR ic -> id
|
||||||
|
lf RSHIFT 5 -> li
|
||||||
|
bp OR bq -> br
|
||||||
|
NOT gs -> gt
|
||||||
|
fo RSHIFT 1 -> gh
|
||||||
|
bz AND cb -> cc
|
||||||
|
ea OR eb -> ec
|
||||||
|
lf AND lq -> ls
|
||||||
|
NOT l -> m
|
||||||
|
hz RSHIFT 3 -> ib
|
||||||
|
NOT di -> dj
|
||||||
|
NOT lk -> ll
|
||||||
|
jp RSHIFT 3 -> jr
|
||||||
|
jp RSHIFT 5 -> js
|
||||||
|
NOT bf -> bg
|
||||||
|
s LSHIFT 15 -> w
|
||||||
|
eq LSHIFT 1 -> fk
|
||||||
|
jl OR jk -> jm
|
||||||
|
hz AND ik -> im
|
||||||
|
dz OR ef -> eg
|
||||||
|
1 AND gy -> gz
|
||||||
|
la LSHIFT 15 -> le
|
||||||
|
br AND bt -> bu
|
||||||
|
NOT cn -> co
|
||||||
|
v OR w -> x
|
||||||
|
d OR j -> k
|
||||||
|
1 AND gd -> ge
|
||||||
|
ia OR ig -> ih
|
||||||
|
NOT go -> gp
|
||||||
|
NOT ed -> ee
|
||||||
|
jq AND jw -> jy
|
||||||
|
et OR fe -> ff
|
||||||
|
aw AND ay -> az
|
||||||
|
ff AND fh -> fi
|
||||||
|
ir LSHIFT 1 -> jl
|
||||||
|
gg LSHIFT 1 -> ha
|
||||||
|
x RSHIFT 2 -> y
|
||||||
|
db OR dc -> dd
|
||||||
|
bl OR bm -> bn
|
||||||
|
ib AND ic -> ie
|
||||||
|
x RSHIFT 3 -> z
|
||||||
|
lh AND li -> lk
|
||||||
|
ce OR cd -> cf
|
||||||
|
NOT bb -> bc
|
||||||
|
hi AND hk -> hl
|
||||||
|
NOT gb -> gc
|
||||||
|
1 AND r -> s
|
||||||
|
fw AND fy -> fz
|
||||||
|
fb AND fd -> fe
|
||||||
|
1 AND en -> eo
|
||||||
|
z OR aa -> ab
|
||||||
|
bi LSHIFT 15 -> bm
|
||||||
|
hg OR hh -> hi
|
||||||
|
kh LSHIFT 1 -> lb
|
||||||
|
cg OR ch -> ci
|
||||||
|
1 AND kz -> la
|
||||||
|
gf OR ge -> gg
|
||||||
|
gj RSHIFT 2 -> gk
|
||||||
|
dd RSHIFT 2 -> de
|
||||||
|
NOT ls -> lt
|
||||||
|
lh OR li -> lj
|
||||||
|
jr OR js -> jt
|
||||||
|
au AND av -> ax
|
||||||
|
0 -> c
|
||||||
|
he AND hp -> hr
|
||||||
|
id AND if -> ig
|
||||||
|
et RSHIFT 5 -> ew
|
||||||
|
bp AND bq -> bs
|
||||||
|
e AND f -> h
|
||||||
|
ly OR lz -> ma
|
||||||
|
1 AND lu -> lv
|
||||||
|
NOT jd -> je
|
||||||
|
ha OR gz -> hb
|
||||||
|
dy RSHIFT 1 -> er
|
||||||
|
iu RSHIFT 2 -> iv
|
||||||
|
NOT hr -> hs
|
||||||
|
as RSHIFT 1 -> bl
|
||||||
|
kk RSHIFT 2 -> kl
|
||||||
|
b AND n -> p
|
||||||
|
ln AND lp -> lq
|
||||||
|
cj AND cp -> cr
|
||||||
|
dl AND dn -> do
|
||||||
|
ci RSHIFT 2 -> cj
|
||||||
|
as OR bd -> be
|
||||||
|
ge LSHIFT 15 -> gi
|
||||||
|
hz RSHIFT 5 -> ic
|
||||||
|
dv LSHIFT 1 -> ep
|
||||||
|
kl OR kr -> ks
|
||||||
|
gj OR gu -> gv
|
||||||
|
he RSHIFT 5 -> hh
|
||||||
|
NOT fg -> fh
|
||||||
|
hg AND hh -> hj
|
||||||
|
b OR n -> o
|
||||||
|
jk LSHIFT 15 -> jo
|
||||||
|
gz LSHIFT 15 -> hd
|
||||||
|
cy LSHIFT 15 -> dc
|
||||||
|
kk RSHIFT 5 -> kn
|
||||||
|
ci RSHIFT 3 -> ck
|
||||||
|
at OR az -> ba
|
||||||
|
iu RSHIFT 3 -> iw
|
||||||
|
ko AND kq -> kr
|
||||||
|
NOT eh -> ei
|
||||||
|
aq OR ar -> as
|
||||||
|
iy AND ja -> jb
|
||||||
|
dd RSHIFT 3 -> df
|
||||||
|
bn RSHIFT 3 -> bp
|
||||||
|
1 AND cc -> cd
|
||||||
|
at AND az -> bb
|
||||||
|
x OR ai -> aj
|
||||||
|
kk AND kv -> kx
|
||||||
|
ao OR an -> ap
|
||||||
|
dy RSHIFT 3 -> ea
|
||||||
|
x RSHIFT 1 -> aq
|
||||||
|
eu AND fa -> fc
|
||||||
|
kl AND kr -> kt
|
||||||
|
ia AND ig -> ii
|
||||||
|
df AND dg -> di
|
||||||
|
NOT fx -> fy
|
||||||
|
k AND m -> n
|
||||||
|
bn RSHIFT 5 -> bq
|
||||||
|
km AND kn -> kp
|
||||||
|
dt LSHIFT 15 -> dx
|
||||||
|
hz RSHIFT 2 -> ia
|
||||||
|
aj AND al -> am
|
||||||
|
cd LSHIFT 15 -> ch
|
||||||
|
hc OR hd -> he
|
||||||
|
he RSHIFT 3 -> hg
|
||||||
|
bn OR by -> bz
|
||||||
|
NOT kt -> ku
|
||||||
|
z AND aa -> ac
|
||||||
|
NOT ak -> al
|
||||||
|
cu AND cw -> cx
|
||||||
|
NOT ie -> if
|
||||||
|
dy RSHIFT 2 -> dz
|
||||||
|
ip LSHIFT 15 -> it
|
||||||
|
de OR dk -> dl
|
||||||
|
au OR av -> aw
|
||||||
|
jg AND ji -> jj
|
||||||
|
ci AND ct -> cv
|
||||||
|
dy RSHIFT 5 -> eb
|
||||||
|
hx OR hy -> hz
|
||||||
|
eu OR fa -> fb
|
||||||
|
gj RSHIFT 3 -> gl
|
||||||
|
fo AND fz -> gb
|
||||||
|
1 AND jj -> jk
|
||||||
|
jp OR ka -> kb
|
||||||
|
de AND dk -> dm
|
||||||
|
ex AND ez -> fa
|
||||||
|
df OR dg -> dh
|
||||||
|
iv OR jb -> jc
|
||||||
|
x RSHIFT 5 -> aa
|
||||||
|
NOT hj -> hk
|
||||||
|
NOT im -> in
|
||||||
|
fl LSHIFT 1 -> gf
|
||||||
|
hu LSHIFT 15 -> hy
|
||||||
|
iq OR ip -> ir
|
||||||
|
iu RSHIFT 5 -> ix
|
||||||
|
NOT fc -> fd
|
||||||
|
NOT el -> em
|
||||||
|
ck OR cl -> cm
|
||||||
|
et RSHIFT 3 -> ev
|
||||||
|
hw LSHIFT 1 -> iq
|
||||||
|
ci RSHIFT 5 -> cl
|
||||||
|
iv AND jb -> jd
|
||||||
|
dd RSHIFT 5 -> dg
|
||||||
|
as RSHIFT 2 -> at
|
||||||
|
NOT jy -> jz
|
||||||
|
af AND ah -> ai
|
||||||
|
1 AND ds -> dt
|
||||||
|
jx AND jz -> ka
|
||||||
|
da LSHIFT 1 -> du
|
||||||
|
fs AND fu -> fv
|
||||||
|
jp RSHIFT 1 -> ki
|
||||||
|
iw AND ix -> iz
|
||||||
|
iw OR ix -> iy
|
||||||
|
eo LSHIFT 15 -> es
|
||||||
|
ev AND ew -> ey
|
||||||
|
ba AND bc -> bd
|
||||||
|
fp AND fv -> fx
|
||||||
|
jc AND je -> jf
|
||||||
|
et RSHIFT 2 -> eu
|
||||||
|
kg OR kf -> kh
|
||||||
|
iu OR jf -> jg
|
||||||
|
er OR es -> et
|
||||||
|
fo RSHIFT 2 -> fp
|
||||||
|
NOT ca -> cb
|
||||||
|
bv AND bx -> by
|
||||||
|
u LSHIFT 1 -> ao
|
||||||
|
cm AND co -> cp
|
||||||
|
y OR ae -> af
|
||||||
|
bn AND by -> ca
|
||||||
|
1 AND ke -> kf
|
||||||
|
jt AND jv -> jw
|
||||||
|
fq OR fr -> fs
|
||||||
|
dy AND ej -> el
|
||||||
|
NOT kc -> kd
|
||||||
|
ev OR ew -> ex
|
||||||
|
dd OR do -> dp
|
||||||
|
NOT cv -> cw
|
||||||
|
gr AND gt -> gu
|
||||||
|
dd RSHIFT 1 -> dw
|
||||||
|
NOT gw -> gx
|
||||||
|
NOT iz -> ja
|
||||||
|
1 AND io -> ip
|
||||||
|
NOT ag -> ah
|
||||||
|
b RSHIFT 5 -> f
|
||||||
|
NOT cr -> cs
|
||||||
|
kb AND kd -> ke
|
||||||
|
jr AND js -> ju
|
||||||
|
cq AND cs -> ct
|
||||||
|
il AND in -> io
|
||||||
|
NOT ju -> jv
|
||||||
|
du OR dt -> dv
|
||||||
|
dd AND do -> dq
|
||||||
|
b RSHIFT 2 -> d
|
||||||
|
jm LSHIFT 1 -> kg
|
||||||
|
NOT dq -> dr
|
||||||
|
bo OR bu -> bv
|
||||||
|
gk OR gq -> gr
|
||||||
|
he OR hp -> hq
|
||||||
|
NOT h -> i
|
||||||
|
hf AND hl -> hn
|
||||||
|
gv AND gx -> gy
|
||||||
|
x AND ai -> ak
|
||||||
|
bo AND bu -> bw
|
||||||
|
hq AND hs -> ht
|
||||||
|
hz RSHIFT 1 -> is
|
||||||
|
gj RSHIFT 5 -> gm
|
||||||
|
g AND i -> j
|
||||||
|
gk AND gq -> gs
|
||||||
|
dp AND dr -> ds
|
||||||
|
b RSHIFT 3 -> e
|
||||||
|
gl AND gm -> go
|
||||||
|
gl OR gm -> gn
|
||||||
|
y AND ae -> ag
|
||||||
|
hv OR hu -> hw
|
||||||
|
1674 -> b
|
||||||
|
ab AND ad -> ae
|
||||||
|
NOT ac -> ad
|
||||||
|
1 AND ht -> hu
|
||||||
|
NOT hn -> ho
|
16
TypeScript/day7/package.json
Normal file
16
TypeScript/day7/package.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"lint": "prettier solution_a.ts solution_b.ts --write --print-width=180",
|
||||||
|
"a": "ts-node solution_a.ts",
|
||||||
|
"b": "ts-node solution_b.ts"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^2.1.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "^14.14.8",
|
||||||
|
"ts-node": "^9.0.0",
|
||||||
|
"typescript": "^4.0.5"
|
||||||
|
},
|
||||||
|
"license": "WTFPL"
|
||||||
|
}
|
64
TypeScript/day7/solution_a.ts
Normal file
64
TypeScript/day7/solution_a.ts
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import fs from "fs";
|
||||||
|
const input = fs.readFileSync("input").toString().split("\n");
|
||||||
|
const COMMAND_REGEX = /[A-Z]+/g;
|
||||||
|
const ARGUMENTS_REGEX = /[a-z0-9]+/g;
|
||||||
|
|
||||||
|
// Dictionary of our bitwise methods
|
||||||
|
const BITWISE_METHODS = {
|
||||||
|
AND: (a: number, b: number) => a & b,
|
||||||
|
OR: (a: number, b: number) => a | b,
|
||||||
|
NOT: (a: number, b?: number) => ~a,
|
||||||
|
LSHIFT: (a: number, b: number) => a << b,
|
||||||
|
RSHIFT: (a: number, b: number) => a >> b,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parse instruction from input and return object with command, arguments and destination wire
|
||||||
|
function parseInstruction(instruction: string): Instruction & { destination: string } {
|
||||||
|
const raw_command = instruction.match(COMMAND_REGEX);
|
||||||
|
const args = instruction.match(ARGUMENTS_REGEX) ?? [];
|
||||||
|
const destination = args.pop()!;
|
||||||
|
const command = raw_command === null ? raw_command : (raw_command[0] as keyof typeof BITWISE_METHODS);
|
||||||
|
|
||||||
|
return {
|
||||||
|
command,
|
||||||
|
args: args.map((arg) => (isNaN(Number(arg)) ? arg : Number(arg))) as [Wire | number, Wire | number | undefined],
|
||||||
|
destination,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type Wire = string;
|
||||||
|
type Instruction = {
|
||||||
|
command: keyof typeof BITWISE_METHODS | null;
|
||||||
|
args: [Wire | number, Wire | number | undefined];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Calculate value for one of the wires (recursively)
|
||||||
|
function calculateWire(wireName: Wire, wires: Map<Wire, any>) {
|
||||||
|
const wire = wires.get(wireName);
|
||||||
|
|
||||||
|
if (typeof wireName === "number") return wireName;
|
||||||
|
if (typeof wire === "number") return wire;
|
||||||
|
if (typeof wire === "undefined") return undefined;
|
||||||
|
|
||||||
|
if (!wire.command) {
|
||||||
|
wires.set(wireName, calculateWire(wire.args[0], wires));
|
||||||
|
} else if (Object.keys(BITWISE_METHODS).includes(wire.command)) {
|
||||||
|
wires.set(wireName, BITWISE_METHODS[wire.command as keyof typeof BITWISE_METHODS](calculateWire(wire.args[0], wires), calculateWire(wire.args[1], wires)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return wires.get(wireName);
|
||||||
|
}
|
||||||
|
async function main() {
|
||||||
|
// Our parsed wires in format {wire: value} or {wire: instruction}
|
||||||
|
const wires = new Map<Wire, Instruction>();
|
||||||
|
|
||||||
|
// Fill WIRES with parsed instructions and their future values
|
||||||
|
input.forEach((instruction) => {
|
||||||
|
const parsedInstruction = parseInstruction(instruction.trim());
|
||||||
|
wires.set(parsedInstruction.destination, { command: parsedInstruction.command, args: parsedInstruction.args });
|
||||||
|
});
|
||||||
|
|
||||||
|
return calculateWire("a", wires);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().then(console.log).catch(console.error);
|
66
TypeScript/day7/solution_b.ts
Normal file
66
TypeScript/day7/solution_b.ts
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
import fs from "fs";
|
||||||
|
const input = fs.readFileSync("input").toString().split("\n");
|
||||||
|
const COMMAND_REGEX = /[A-Z]+/g;
|
||||||
|
const ARGUMENTS_REGEX = /[a-z0-9]+/g;
|
||||||
|
|
||||||
|
// Dictionary of our bitwise methods
|
||||||
|
const BITWISE_METHODS = {
|
||||||
|
AND: (a: number, b: number) => a & b,
|
||||||
|
OR: (a: number, b: number) => a | b,
|
||||||
|
NOT: (a: number, b?: number) => ~a,
|
||||||
|
LSHIFT: (a: number, b: number) => a << b,
|
||||||
|
RSHIFT: (a: number, b: number) => a >> b,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parse instruction from input and return object with command, arguments and destination wire
|
||||||
|
function parseInstruction(instruction: string): Instruction & { destination: string } {
|
||||||
|
const raw_command = instruction.match(COMMAND_REGEX);
|
||||||
|
const args = instruction.match(ARGUMENTS_REGEX) ?? [];
|
||||||
|
const destination = args.pop()!;
|
||||||
|
const command = raw_command === null ? raw_command : (raw_command[0] as keyof typeof BITWISE_METHODS);
|
||||||
|
|
||||||
|
return {
|
||||||
|
command,
|
||||||
|
args: args.map((arg) => (isNaN(Number(arg)) ? arg : Number(arg))) as [Wire | number, Wire | number | undefined],
|
||||||
|
destination,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type Wire = string;
|
||||||
|
type Instruction = {
|
||||||
|
command: keyof typeof BITWISE_METHODS | null;
|
||||||
|
args: [Wire | number, Wire | number | undefined];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Calculate value for one of the wires (recursively)
|
||||||
|
function calculateWire(wireName: Wire, wires: Map<Wire, any>) {
|
||||||
|
const wire = wires.get(wireName);
|
||||||
|
|
||||||
|
if (typeof wireName === "number") return wireName;
|
||||||
|
if (typeof wire === "number") return wire;
|
||||||
|
if (typeof wire === "undefined") return undefined;
|
||||||
|
|
||||||
|
if (!wire.command) {
|
||||||
|
wires.set(wireName, calculateWire(wire.args[0], wires));
|
||||||
|
} else if (Object.keys(BITWISE_METHODS).includes(wire.command)) {
|
||||||
|
wires.set(wireName, BITWISE_METHODS[wire.command as keyof typeof BITWISE_METHODS](calculateWire(wire.args[0], wires), calculateWire(wire.args[1], wires)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return wires.get(wireName);
|
||||||
|
}
|
||||||
|
async function main() {
|
||||||
|
// Our parsed wires in format {wire: value} or {wire: instruction}
|
||||||
|
const wires = new Map<Wire, Instruction>();
|
||||||
|
|
||||||
|
// Fill WIRES with parsed instructions and their future values
|
||||||
|
input.forEach((instruction) => {
|
||||||
|
const parsedInstruction = parseInstruction(instruction.trim());
|
||||||
|
wires.set(parsedInstruction.destination, { command: parsedInstruction.command, args: parsedInstruction.args });
|
||||||
|
});
|
||||||
|
const parsedInstruction = parseInstruction("46065 -> b");
|
||||||
|
wires.set(parsedInstruction.destination, { command: parsedInstruction.command, args: parsedInstruction.args });
|
||||||
|
|
||||||
|
return calculateWire("a", wires);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().then(console.log).catch(console.error);
|
69
TypeScript/day7/tsconfig.json
Normal file
69
TypeScript/day7/tsconfig.json
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||||
|
|
||||||
|
/* Basic Options */
|
||||||
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
|
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||||
|
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||||
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||||
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||||
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
|
"sourceMap": false, /* Generates corresponding '.map' file. */
|
||||||
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||||
|
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||||
|
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
|
// "composite": true, /* Enable project compilation */
|
||||||
|
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||||
|
// "removeComments": true, /* Do not emit comments to output. */
|
||||||
|
"noEmit": true, /* Do not emit outputs. */
|
||||||
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||||
|
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||||
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||||
|
|
||||||
|
/* Strict Type-Checking Options */
|
||||||
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
|
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||||
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
|
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
|
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||||
|
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||||
|
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
|
||||||
|
/* Additional Checks */
|
||||||
|
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||||
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
|
||||||
|
/* Module Resolution Options */
|
||||||
|
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||||
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
|
||||||
|
/* Source Map Options */
|
||||||
|
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||||
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
|
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||||
|
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||||
|
|
||||||
|
/* Experimental Options */
|
||||||
|
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||||
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||||
|
|
||||||
|
/* Advanced Options */
|
||||||
|
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||||
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||||
|
}
|
||||||
|
}
|
67
TypeScript/day7/yarn.lock
Normal file
67
TypeScript/day7/yarn.lock
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
"@types/node@^14.14.8":
|
||||||
|
version "14.14.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.8.tgz#2127bd81949a95c8b7d3240f3254352d72563aec"
|
||||||
|
integrity sha512-z/5Yd59dCKI5kbxauAJgw6dLPzW+TNOItNE00PkpzNwUIEwdj/Lsqwq94H5DdYBX7C13aRA0CY32BK76+neEUA==
|
||||||
|
|
||||||
|
arg@^4.1.0:
|
||||||
|
version "4.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
|
||||||
|
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
|
||||||
|
|
||||||
|
buffer-from@^1.0.0:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
|
||||||
|
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
|
||||||
|
|
||||||
|
diff@^4.0.1:
|
||||||
|
version "4.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
|
||||||
|
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
|
||||||
|
|
||||||
|
make-error@^1.1.1:
|
||||||
|
version "1.3.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
|
||||||
|
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
|
||||||
|
|
||||||
|
prettier@^2.1.2:
|
||||||
|
version "2.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
|
||||||
|
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==
|
||||||
|
|
||||||
|
source-map-support@^0.5.17:
|
||||||
|
version "0.5.19"
|
||||||
|
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
|
||||||
|
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
|
||||||
|
dependencies:
|
||||||
|
buffer-from "^1.0.0"
|
||||||
|
source-map "^0.6.0"
|
||||||
|
|
||||||
|
source-map@^0.6.0:
|
||||||
|
version "0.6.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||||
|
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||||
|
|
||||||
|
ts-node@^9.0.0:
|
||||||
|
version "9.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.0.0.tgz#e7699d2a110cc8c0d3b831715e417688683460b3"
|
||||||
|
integrity sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==
|
||||||
|
dependencies:
|
||||||
|
arg "^4.1.0"
|
||||||
|
diff "^4.0.1"
|
||||||
|
make-error "^1.1.1"
|
||||||
|
source-map-support "^0.5.17"
|
||||||
|
yn "3.1.1"
|
||||||
|
|
||||||
|
typescript@^4.0.5:
|
||||||
|
version "4.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
|
||||||
|
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
|
||||||
|
|
||||||
|
yn@3.1.1:
|
||||||
|
version "3.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
|
||||||
|
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
|
5
TypeScript/day8/.yarnrc
Normal file
5
TypeScript/day8/.yarnrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
yarn-path ".yarn/releases/yarn-1.22.10.cjs"
|
300
TypeScript/day8/input
Normal file
300
TypeScript/day8/input
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
"azlgxdbljwygyttzkfwuxv"
|
||||||
|
"v\xfb\"lgs\"kvjfywmut\x9cr"
|
||||||
|
"merxdhj"
|
||||||
|
"dwz"
|
||||||
|
"d\\gkbqo\\fwukyxab\"u"
|
||||||
|
"k\xd4cfixejvkicryipucwurq\x7eq"
|
||||||
|
"nvtidemacj\"hppfopvpr"
|
||||||
|
"kbngyfvvsdismznhar\\p\"\"gpryt\"jaeh"
|
||||||
|
"khre\"o\x0elqfrbktzn"
|
||||||
|
"nugkdmqwdq\x50amallrskmrxoyo"
|
||||||
|
"jcrkptrsasjp\\\"cwigzynjgspxxv\\vyb"
|
||||||
|
"ramf\"skhcmenhbpujbqwkltmplxygfcy"
|
||||||
|
"aqjqgbfqaxga\\fkdcahlfi\"pvods"
|
||||||
|
"pcrtfb"
|
||||||
|
"\x83qg\"nwgugfmfpzlrvty\"ryoxm"
|
||||||
|
"fvhvvokdnl\\eap"
|
||||||
|
"kugdkrat"
|
||||||
|
"seuxwc"
|
||||||
|
"vhioftcosshaqtnz"
|
||||||
|
"gzkxqrdq\\uko\"mrtst"
|
||||||
|
"znjcomvy\x16hhsenmroswr"
|
||||||
|
"clowmtra"
|
||||||
|
"\xc4"
|
||||||
|
"jpavsevmziklydtqqm"
|
||||||
|
"egxjqytcttr\\ecfedmmovkyn\"m"
|
||||||
|
"mjulrvqgmsvmwf"
|
||||||
|
"o\\prxtlfbatxerhev\xf9hcl\x44rzmvklviv"
|
||||||
|
"lregjexqaqgwloydxdsc\\o\"dnjfmjcu"
|
||||||
|
"lnxluajtk\x8desue\\k\x7abhwokfhh"
|
||||||
|
"wrssfvzzn\"llrysjgiu\"npjtdli"
|
||||||
|
"\x67lwkks"
|
||||||
|
"bifw\"ybvmwiyi\"vhol\"vol\xd4"
|
||||||
|
"aywdqhvtvcpvbewtwuyxrix"
|
||||||
|
"gc\xd3\"caukdgfdywj"
|
||||||
|
"uczy\\fk"
|
||||||
|
"bnlxkjvl\x7docehufkj\\\"qoyhag"
|
||||||
|
"bidsptalmoicyorbv\\"
|
||||||
|
"jorscv\"mufcvvfmcv\"ga"
|
||||||
|
"sofpwfal\\a"
|
||||||
|
"kcuqtbboaly\"uj\"k"
|
||||||
|
"n\\c"
|
||||||
|
"x\"\xcaj\\xwwvpdldz"
|
||||||
|
"eyukphh"
|
||||||
|
"wcyjq"
|
||||||
|
"vjx\"\"hjroj\"l\x4cjwbr"
|
||||||
|
"xcodsxzfqw\\rowqtuwvjnxupjnrh"
|
||||||
|
"yc"
|
||||||
|
"fpvzldgbdtca\"hqwa"
|
||||||
|
"ymjq\x8ahohvafubra\"hgqoknkuyph"
|
||||||
|
"kx\\mkaaklvcup"
|
||||||
|
"belddrzegcsxsyfhzyz"
|
||||||
|
"fuyswi"
|
||||||
|
"\\hubzebo\"ha\\qyr\"dv\\"
|
||||||
|
"mxvlz\"fwuvx\"cyk\""
|
||||||
|
"ftbh\"ro\\tmcpnpvh\"xx"
|
||||||
|
"ygi"
|
||||||
|
"rw\"\"wwn\\fgbjumq\"vgvoh\xd0\"mm"
|
||||||
|
"\"pat\"\x63kpfc\"\x2ckhfvxk\"uwqzlx"
|
||||||
|
"o"
|
||||||
|
"d\"hqtsfp\xceaswe\"\xc0lw"
|
||||||
|
"zajpvfawqntvoveal\"\"trcdarjua"
|
||||||
|
"xzapq"
|
||||||
|
"rkmhm"
|
||||||
|
"byuq"
|
||||||
|
"rwwmt\xe8jg\xc2\"omt"
|
||||||
|
"nfljgdmgefvlh\"x"
|
||||||
|
"rpjxcexisualz"
|
||||||
|
"doxcycmgaiptvd"
|
||||||
|
"rq\\\"mohnjdf\\xv\\hrnosdtmvxot"
|
||||||
|
"oqvbcenib\"uhy\\npjxg"
|
||||||
|
"pkvgnm\\ruayuvpbpd"
|
||||||
|
"kknmzpxqfbcdgng"
|
||||||
|
"piduhbmaympxdexz"
|
||||||
|
"vapczawekhoa\\or"
|
||||||
|
"tlwn\"avc\"bycg\"\"xuxea"
|
||||||
|
"\xcdvryveteqzxrgopmdmihkcgsuozips"
|
||||||
|
"kpzziqt"
|
||||||
|
"sdy\\s\"cjq"
|
||||||
|
"yujs"
|
||||||
|
"qte\"q"
|
||||||
|
"qyvpnkhjcqjv\"cclvv\"pclgtg\xeak\"tno"
|
||||||
|
"xwx"
|
||||||
|
"vibuvv"
|
||||||
|
"qq\""
|
||||||
|
"wwjduomtbkbdtorhpyalxswisq\"r"
|
||||||
|
"afuw\\mfjzctcivwesutxbk\"lk"
|
||||||
|
"e\xcef\\hkiu"
|
||||||
|
"ftdrgzvygcw\"jwsrcmgxj"
|
||||||
|
"zrddqfkx\x21dr\"ju\"elybk\"powj\"\"kpryz"
|
||||||
|
"dttdkfvbodkma\""
|
||||||
|
"lzygktugpqw"
|
||||||
|
"qu\x83tes\\u\"tnid\"ryuz"
|
||||||
|
"\\o\"pe\\vqwlsizjklwrjofg\xe2oau\\rd"
|
||||||
|
"mikevjzhnwgx\"fozrj\"h\""
|
||||||
|
"ligxmxznzvtachvvbahnff"
|
||||||
|
"d\\kq"
|
||||||
|
"tnbkxpzmcakqhaa"
|
||||||
|
"g\\yeakebeyv"
|
||||||
|
"cqkcnd\"sxjxfnawy\x31zax\x6ceha"
|
||||||
|
"m\x0dtqotffzdnetujtsgjqgwddc"
|
||||||
|
"masnugb\"etgmxul\x3bqd\\tmtddnvcy"
|
||||||
|
"floediikodfgre\x23wyoxlswxflwecdjpt"
|
||||||
|
"zu"
|
||||||
|
"r"
|
||||||
|
"\"ashzdbd\"pdvba\xeeumkr\\amnj"
|
||||||
|
"ckslmuwbtfouwpfwtuiqmeozgspwnhx"
|
||||||
|
"t\\qjsjek\xf9gjcxsyco\"r"
|
||||||
|
"hoed\x1b\\tcmaqch\"epdy"
|
||||||
|
"mgjiojwzc\\ypqcn\xb1njmp\"aeeblxt"
|
||||||
|
"\xdf\"h\x5enfracj"
|
||||||
|
"\x6fpbpocrb"
|
||||||
|
"jbmhrswyyq\\"
|
||||||
|
"wtyqtenfwatji\"ls\\"
|
||||||
|
"voy"
|
||||||
|
"awj"
|
||||||
|
"rtbj\"j"
|
||||||
|
"hynl"
|
||||||
|
"orqqeuaat\\xu\\havsgr\xc5qdk"
|
||||||
|
"g\"npyzjfq\"rjefwsk"
|
||||||
|
"rk\\kkcirjbixr\\zelndx\"bsnqvqj\""
|
||||||
|
"tecoz"
|
||||||
|
"dn\"uswngbdk\""
|
||||||
|
"qb\\"
|
||||||
|
"wpyis\\ebq"
|
||||||
|
"ppwue\\airoxzjjdqbvyurhaabetv"
|
||||||
|
"fxlvt"
|
||||||
|
"ql\"oqsmsvpxcg\"k"
|
||||||
|
"vqlhuec\\adw"
|
||||||
|
"qzmi\xffberakqqkk"
|
||||||
|
"tisjqff\"wf"
|
||||||
|
"yhnpudoaybwucvppj"
|
||||||
|
"xhfuf\\ehsrhsnfxcwtibd\"ubfpz"
|
||||||
|
"ihgjquzhf\""
|
||||||
|
"ff\x66dsupesrnusrtqnywoqcn\\"
|
||||||
|
"z\x77zpubbjmd"
|
||||||
|
"\"vhzlbwq\"xeimjt\\xe\x85umho\"m\"\"bmy"
|
||||||
|
"mmuvkioocmzjjysi\"mkfbec\""
|
||||||
|
"rpgghowbduw\x2fayslubajinoik\xd0hcfy"
|
||||||
|
"xrkyjqul\xdexlojgdphczp\"jfk"
|
||||||
|
"mg\x07cnr\x8b\x67xdgszmgiktpjhawho"
|
||||||
|
"kdgufhaoab"
|
||||||
|
"rlhela\"nldr"
|
||||||
|
"wzye\x87u"
|
||||||
|
"yif\x75bjhnitgoarmfgqwpmopu"
|
||||||
|
"pvlbyez\"wyy\x3dpgr"
|
||||||
|
"ezdm\"ovkruthkvdwtqwr\"ibdoawzgu"
|
||||||
|
"qubp"
|
||||||
|
"b\\kcpegcn\\zgdemgorjnk"
|
||||||
|
"gjsva\\kzaor\"\"gtpd"
|
||||||
|
"\"kt"
|
||||||
|
"rlymwlcodix"
|
||||||
|
"qqtmswowxca\"jvv"
|
||||||
|
"jni\xebwhozb"
|
||||||
|
"zhino\"kzjtmgxpi\"zzexijg"
|
||||||
|
"tyrbat\\mejgzplufxixkyg"
|
||||||
|
"lhmopxiao\x09\"p\xebl"
|
||||||
|
"xefioorxvate"
|
||||||
|
"nmcgd\x46xfujt\"w"
|
||||||
|
"\xe3wnwpat\"gtimrb"
|
||||||
|
"wpq\"xkjuw\xebbohgcagppb"
|
||||||
|
"fmvpwaca"
|
||||||
|
"mlsw"
|
||||||
|
"fdan\\\x9e"
|
||||||
|
"\"f\"fmdlzc"
|
||||||
|
"nyuj\\jnnfzdnrqmhvjrahlvzl"
|
||||||
|
"zn\"f\xcfsshcdaukkimfwk"
|
||||||
|
"uayugezzo\\\"e\"blnrgjaupqhik"
|
||||||
|
"efd\"apkndelkuvfvwyyatyttkehc"
|
||||||
|
"ufxq\\\"m\"bwkh\x93kapbqrvxxzbzp\\"
|
||||||
|
"fgypsbgjak\x79qblbeidavqtddfacq\\i\"h"
|
||||||
|
"kcfgpiysdxlgejjvgndb\\dovfpqodw"
|
||||||
|
"\"onpqnssmighipuqgwx\"nrokzgvg"
|
||||||
|
"vhjrrhfrba\"jebdanzsrdusut\\wbs"
|
||||||
|
"o\xdakymbaxakys"
|
||||||
|
"uwxhhzz\\mtmhghjn\\\\tnhzbejj"
|
||||||
|
"yd\\"
|
||||||
|
"bpgztp\\lzwpdqju\"it\x35qjhihjv"
|
||||||
|
"\\my\\b\"klnnto\\\xb3mbtsh"
|
||||||
|
"ezyvknv\"l\x2bdhhfjcvwzhjgmhwbqd\"\\"
|
||||||
|
"ftkz\"amoncbsohtaumhl\"wsodemopodq"
|
||||||
|
"ifv"
|
||||||
|
"dmzfxvzq"
|
||||||
|
"sped\"bvmf\"mmevl\"zydannpfny"
|
||||||
|
"fjxcjwlv\"pnqyrzatsjwsqfidb"
|
||||||
|
"muc\xfdqouwwnmuixru\\zlhjintplvtee"
|
||||||
|
"mraqgvmj"
|
||||||
|
"njopq\"ftcsryo"
|
||||||
|
"enoh\"n"
|
||||||
|
"t\"ntjhjc\"nzqh\xf7dcohhlsja\x7dtr"
|
||||||
|
"flbqcmcoun"
|
||||||
|
"dxkiysrn\\dyuqoaig"
|
||||||
|
"nehkzi\"h\"syktzfufotng\xdafqo"
|
||||||
|
"dzkjg\\hqjk\\\"zfegssjhn"
|
||||||
|
"sadlsjv"
|
||||||
|
"vmfnrdb\""
|
||||||
|
"ac\\bdp\"n"
|
||||||
|
"qt\x89h"
|
||||||
|
"lsndeugwvijwde\\vjapbm\\k\\nljuva"
|
||||||
|
"twpmltdzyynqt\\z\\tnund\x64hm"
|
||||||
|
"hpcyata\"ocylbkzdnhujh"
|
||||||
|
"hskzq\"knntuhscex\"q\\y\\vqj\x3an"
|
||||||
|
"eekwyufvji\\mqgeroekxeyrmymq"
|
||||||
|
"hl\"durthetvri\xebw\\jxu\"rcmiuy"
|
||||||
|
"\"fxdnmvnftxwesmvvq\"sjnf\xaabpg\"iary"
|
||||||
|
"\"\"nksqso"
|
||||||
|
"ruq\xbezugge\"d\"hwvoxmy\"iawikddxn\"x"
|
||||||
|
"rxxnlfay"
|
||||||
|
"stcu\"mv\xabcqts\\fasff"
|
||||||
|
"yrnvwfkfuzuoysfdzl\x02bk"
|
||||||
|
"qbdsmlwdbfknivtwijbwtatqfe"
|
||||||
|
"\"erqh\\csjph"
|
||||||
|
"ikfv"
|
||||||
|
"\xd2cuhowmtsxepzsivsvnvsb"
|
||||||
|
"vj"
|
||||||
|
"d"
|
||||||
|
"\\g"
|
||||||
|
"porvg\x62qghorthnc\"\\"
|
||||||
|
"tiks\\kr\"\x0fuejvuxzswnwdjscrk"
|
||||||
|
"xmgfel\"atma\\zaxmlgfjx\"ajmqf"
|
||||||
|
"oz\\rnxwljc\\\"umhymtwh"
|
||||||
|
"wlsxxhm\x7fqx\\gjoyrvccfiner\\qloluqv"
|
||||||
|
"k\\ieq"
|
||||||
|
"xidjj\"ksnlgnwxlddf\\s\\kuuleb"
|
||||||
|
"wjpnzgprzv\\maub\x0cj"
|
||||||
|
"r"
|
||||||
|
"y"
|
||||||
|
"\"yecqiei\"ire\\jdhlnnlde\xc5u"
|
||||||
|
"drvdiycqib"
|
||||||
|
"egnrbefezcrhgldrtb"
|
||||||
|
"plqodxv\\zm\"uodwjdocri\x55ucaezutm"
|
||||||
|
"f\"wexcw\x02ekewx\"alyzn"
|
||||||
|
"pqajwuk\\\\oatkfqdyspnrupo"
|
||||||
|
"rkczj\"fzntabpnygrhamk\\km\x68xfkmr"
|
||||||
|
"wejam\xbac\x37kns"
|
||||||
|
"qqmlwjk\"gh"
|
||||||
|
"fdcjsxlgx"
|
||||||
|
"\\cxvxy\"kb\"\"unubvrsq\\y\\awfhbmarj\\"
|
||||||
|
"geunceaqr"
|
||||||
|
"tpkg\"svvngk\\sizlsyaqwf"
|
||||||
|
"\"pa\\x\x18od\\emgje\\"
|
||||||
|
"ffiizogjjptubzqfuh\"cctieqcdh"
|
||||||
|
"yikhiyyrpgglpos"
|
||||||
|
"h\\"
|
||||||
|
"jotqojodcv"
|
||||||
|
"ervsz\x87ade\"fevq\\tcqowt"
|
||||||
|
"\\y\"fgrxtppkcseeg\\onxjarx\\hyhfn\x5fi"
|
||||||
|
"kxndlabn\\wwumctuzdcfiitrbnn"
|
||||||
|
"eoosynwhwm"
|
||||||
|
"\"c\x04"
|
||||||
|
"ny\xf6vuwlec"
|
||||||
|
"ubgxxcvnltzaucrzg\\xcez"
|
||||||
|
"pnocjvo\\yt"
|
||||||
|
"fcabrtqog\"a\"zj"
|
||||||
|
"o\\bha\\mzxmrfltnflv\xea"
|
||||||
|
"tbfvzwhexsdxjmxejwqqngzixcx"
|
||||||
|
"wdptrakok\"rgymturdmwfiwu"
|
||||||
|
"reffmj"
|
||||||
|
"lqm"
|
||||||
|
"\\oc"
|
||||||
|
"p\""
|
||||||
|
"ygkdnhcuehlx"
|
||||||
|
"vsqmv\"bqay\"olimtkewedzm"
|
||||||
|
"isos\x6azbnkojhxoopzetbj\xe1yd"
|
||||||
|
"yo\\pgayjcyhshztnbdv"
|
||||||
|
"fg\"h"
|
||||||
|
"vcmcojolfcf\\\\oxveua"
|
||||||
|
"w\"vyszhbrr\"jpeddpnrjlca\x69bdbopd\\z"
|
||||||
|
"jikeqv"
|
||||||
|
"\"dkjdfrtj"
|
||||||
|
"is"
|
||||||
|
"hgzx"
|
||||||
|
"z\""
|
||||||
|
"woubquq\\ag\""
|
||||||
|
"xvclriqa\xe6ltt"
|
||||||
|
"tfxinifmd"
|
||||||
|
"mvywzf\"jz"
|
||||||
|
"vlle"
|
||||||
|
"c\"rf\"wynhye\x25vccvb\""
|
||||||
|
"zvuxm"
|
||||||
|
"\xf2\"jdstiwqer\"h"
|
||||||
|
"kyogyogcknbzv\x9f\\\\e"
|
||||||
|
"kspodj\"edpeqgypc"
|
||||||
|
"oh\\x\\h"
|
||||||
|
"julb"
|
||||||
|
"bmcfkidxyilgoy\\xmu\"ig\\qg"
|
||||||
|
"veqww\"ea"
|
||||||
|
"fkdbemtgtkpqisrwlxutllxc\"mbelhs"
|
||||||
|
"e"
|
||||||
|
"ecn\x50ooprbstnq"
|
||||||
|
"\"\xe8\"ec\xeah\"qo\\g\"iuqxy\"e\"y\xe7xk\xc6d"
|
||||||
|
"lwj\"aftrcqj"
|
||||||
|
"jduij\x97zk\"rftjrixzgscxxllpqx\"bwwb"
|
||||||
|
"fqcditz"
|
||||||
|
"f\x19azclj\"rsvaokgvty\"aeq"
|
||||||
|
"erse\x9etmzhlmhy\x67yftoti"
|
||||||
|
"lsdw\xb3dmiy\\od"
|
||||||
|
"x\x6fxbljsjdgd\xaau"
|
||||||
|
"hjg\\w\"\x78uoqbsdikbjxpip\"w\"jnhzec"
|
||||||
|
"gk"
|
||||||
|
"\\zrs\\syur"
|
16
TypeScript/day8/package.json
Normal file
16
TypeScript/day8/package.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"lint": "prettier solution_a.ts solution_b.ts --write --print-width=120",
|
||||||
|
"a": "ts-node solution_a.ts",
|
||||||
|
"b": "ts-node solution_b.ts"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^2.1.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "^14.14.8",
|
||||||
|
"ts-node": "^9.0.0",
|
||||||
|
"typescript": "^4.0.5"
|
||||||
|
},
|
||||||
|
"license": "WTFPL"
|
||||||
|
}
|
9
TypeScript/day8/solution_a.ts
Normal file
9
TypeScript/day8/solution_a.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import * as fs from "fs";
|
||||||
|
const input = fs.readFileSync("input").toString();
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const lines = input.split("\n").map((line) => line.trim());
|
||||||
|
return lines.reduce((prev, line) => prev + (line.length - eval(line).length), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().then(console.log).catch(console.error);
|
15
TypeScript/day8/solution_b.ts
Normal file
15
TypeScript/day8/solution_b.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import * as fs from "fs";
|
||||||
|
const input = fs.readFileSync("input").toString();
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const lines = input.split("\n").map((line) => line.trim());
|
||||||
|
let result = 0;
|
||||||
|
for (const line of lines) {
|
||||||
|
const replaced = '"' + line.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"';
|
||||||
|
result += replaced.length - line.length;
|
||||||
|
console.log(line, replaced);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
main().then(console.log).catch(console.error);
|
69
TypeScript/day8/tsconfig.json
Normal file
69
TypeScript/day8/tsconfig.json
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||||
|
|
||||||
|
/* Basic Options */
|
||||||
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
|
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||||
|
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||||
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||||
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||||
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
|
"sourceMap": false, /* Generates corresponding '.map' file. */
|
||||||
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||||
|
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||||
|
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
|
// "composite": true, /* Enable project compilation */
|
||||||
|
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||||
|
// "removeComments": true, /* Do not emit comments to output. */
|
||||||
|
"noEmit": true, /* Do not emit outputs. */
|
||||||
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||||
|
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||||
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||||
|
|
||||||
|
/* Strict Type-Checking Options */
|
||||||
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
|
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||||
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
|
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
|
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||||
|
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||||
|
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
|
||||||
|
/* Additional Checks */
|
||||||
|
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||||
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
|
||||||
|
/* Module Resolution Options */
|
||||||
|
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||||
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
|
||||||
|
/* Source Map Options */
|
||||||
|
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||||
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
|
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||||
|
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||||
|
|
||||||
|
/* Experimental Options */
|
||||||
|
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||||
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||||
|
|
||||||
|
/* Advanced Options */
|
||||||
|
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||||
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||||
|
}
|
||||||
|
}
|
67
TypeScript/day8/yarn.lock
Normal file
67
TypeScript/day8/yarn.lock
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
"@types/node@^14.14.8":
|
||||||
|
version "14.14.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.8.tgz#2127bd81949a95c8b7d3240f3254352d72563aec"
|
||||||
|
integrity sha512-z/5Yd59dCKI5kbxauAJgw6dLPzW+TNOItNE00PkpzNwUIEwdj/Lsqwq94H5DdYBX7C13aRA0CY32BK76+neEUA==
|
||||||
|
|
||||||
|
arg@^4.1.0:
|
||||||
|
version "4.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
|
||||||
|
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
|
||||||
|
|
||||||
|
buffer-from@^1.0.0:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
|
||||||
|
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
|
||||||
|
|
||||||
|
diff@^4.0.1:
|
||||||
|
version "4.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
|
||||||
|
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
|
||||||
|
|
||||||
|
make-error@^1.1.1:
|
||||||
|
version "1.3.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
|
||||||
|
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
|
||||||
|
|
||||||
|
prettier@^2.1.2:
|
||||||
|
version "2.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
|
||||||
|
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==
|
||||||
|
|
||||||
|
source-map-support@^0.5.17:
|
||||||
|
version "0.5.19"
|
||||||
|
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
|
||||||
|
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
|
||||||
|
dependencies:
|
||||||
|
buffer-from "^1.0.0"
|
||||||
|
source-map "^0.6.0"
|
||||||
|
|
||||||
|
source-map@^0.6.0:
|
||||||
|
version "0.6.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||||
|
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||||
|
|
||||||
|
ts-node@^9.0.0:
|
||||||
|
version "9.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.0.0.tgz#e7699d2a110cc8c0d3b831715e417688683460b3"
|
||||||
|
integrity sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==
|
||||||
|
dependencies:
|
||||||
|
arg "^4.1.0"
|
||||||
|
diff "^4.0.1"
|
||||||
|
make-error "^1.1.1"
|
||||||
|
source-map-support "^0.5.17"
|
||||||
|
yn "3.1.1"
|
||||||
|
|
||||||
|
typescript@^4.0.5:
|
||||||
|
version "4.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
|
||||||
|
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
|
||||||
|
|
||||||
|
yn@3.1.1:
|
||||||
|
version "3.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
|
||||||
|
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
|
147392
TypeScript/template/.yarn/releases/yarn-1.22.10.cjs
vendored
Normal file
147392
TypeScript/template/.yarn/releases/yarn-1.22.10.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
5
TypeScript/template/.yarnrc
Normal file
5
TypeScript/template/.yarnrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
yarn-path ".yarn/releases/yarn-1.22.10.cjs"
|
0
TypeScript/template/input
Normal file
0
TypeScript/template/input
Normal file
16
TypeScript/template/package.json
Normal file
16
TypeScript/template/package.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"lint": "prettier solution_a.ts solution_b.ts --write --print-width=120",
|
||||||
|
"a": "ts-node solution_a.ts",
|
||||||
|
"b": "ts-node solution_b.ts"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^2.1.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "^14.14.8",
|
||||||
|
"ts-node": "^9.0.0",
|
||||||
|
"typescript": "^4.0.5"
|
||||||
|
},
|
||||||
|
"license": "WTFPL"
|
||||||
|
}
|
6
TypeScript/template/solution_a.ts
Normal file
6
TypeScript/template/solution_a.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import * as fs from "fs";
|
||||||
|
const input = fs.readFileSync("input").toString();
|
||||||
|
|
||||||
|
async function main() {}
|
||||||
|
|
||||||
|
main().then(console.log).catch(console.error);
|
6
TypeScript/template/solution_b.ts
Normal file
6
TypeScript/template/solution_b.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import * as fs from "fs";
|
||||||
|
const input = fs.readFileSync("input").toString();
|
||||||
|
|
||||||
|
async function main() {}
|
||||||
|
|
||||||
|
main().then(console.log).catch(console.error);
|
69
TypeScript/template/tsconfig.json
Normal file
69
TypeScript/template/tsconfig.json
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||||
|
|
||||||
|
/* Basic Options */
|
||||||
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
|
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||||
|
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||||
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||||
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||||
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
|
"sourceMap": false, /* Generates corresponding '.map' file. */
|
||||||
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||||
|
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||||
|
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
|
// "composite": true, /* Enable project compilation */
|
||||||
|
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||||
|
// "removeComments": true, /* Do not emit comments to output. */
|
||||||
|
"noEmit": true, /* Do not emit outputs. */
|
||||||
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||||
|
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||||
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||||
|
|
||||||
|
/* Strict Type-Checking Options */
|
||||||
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
|
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||||
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
|
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
|
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||||
|
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||||
|
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
|
||||||
|
/* Additional Checks */
|
||||||
|
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||||
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
|
||||||
|
/* Module Resolution Options */
|
||||||
|
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||||
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
|
||||||
|
/* Source Map Options */
|
||||||
|
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||||
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
|
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||||
|
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||||
|
|
||||||
|
/* Experimental Options */
|
||||||
|
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||||
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||||
|
|
||||||
|
/* Advanced Options */
|
||||||
|
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||||
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||||
|
}
|
||||||
|
}
|
67
TypeScript/template/yarn.lock
Normal file
67
TypeScript/template/yarn.lock
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
"@types/node@^14.14.8":
|
||||||
|
version "14.14.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.8.tgz#2127bd81949a95c8b7d3240f3254352d72563aec"
|
||||||
|
integrity sha512-z/5Yd59dCKI5kbxauAJgw6dLPzW+TNOItNE00PkpzNwUIEwdj/Lsqwq94H5DdYBX7C13aRA0CY32BK76+neEUA==
|
||||||
|
|
||||||
|
arg@^4.1.0:
|
||||||
|
version "4.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
|
||||||
|
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
|
||||||
|
|
||||||
|
buffer-from@^1.0.0:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
|
||||||
|
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
|
||||||
|
|
||||||
|
diff@^4.0.1:
|
||||||
|
version "4.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
|
||||||
|
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
|
||||||
|
|
||||||
|
make-error@^1.1.1:
|
||||||
|
version "1.3.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
|
||||||
|
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
|
||||||
|
|
||||||
|
prettier@^2.1.2:
|
||||||
|
version "2.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
|
||||||
|
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==
|
||||||
|
|
||||||
|
source-map-support@^0.5.17:
|
||||||
|
version "0.5.19"
|
||||||
|
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
|
||||||
|
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
|
||||||
|
dependencies:
|
||||||
|
buffer-from "^1.0.0"
|
||||||
|
source-map "^0.6.0"
|
||||||
|
|
||||||
|
source-map@^0.6.0:
|
||||||
|
version "0.6.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||||
|
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||||
|
|
||||||
|
ts-node@^9.0.0:
|
||||||
|
version "9.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.0.0.tgz#e7699d2a110cc8c0d3b831715e417688683460b3"
|
||||||
|
integrity sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==
|
||||||
|
dependencies:
|
||||||
|
arg "^4.1.0"
|
||||||
|
diff "^4.0.1"
|
||||||
|
make-error "^1.1.1"
|
||||||
|
source-map-support "^0.5.17"
|
||||||
|
yn "3.1.1"
|
||||||
|
|
||||||
|
typescript@^4.0.5:
|
||||||
|
version "4.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
|
||||||
|
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
|
||||||
|
|
||||||
|
yn@3.1.1:
|
||||||
|
version "3.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
|
||||||
|
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
|
|
@ -1 +0,0 @@
|
||||||
404 Not Found
|
|
|
@ -1,53 +0,0 @@
|
||||||
pub const INPUT: &str = include_str!("./input.txt");
|
|
||||||
|
|
||||||
type Input = &'static str;
|
|
||||||
type Output = usize;
|
|
||||||
|
|
||||||
fn parse_input(input: &'static str) -> Input {
|
|
||||||
input
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let input = parse_input(INPUT);
|
|
||||||
println!("Part 1: {}", part_1(&input));
|
|
||||||
println!("Part 2: {}", part_2(&input));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_1(input: &Input) -> Output {
|
|
||||||
Output::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_2(input: &Input) -> Output {
|
|
||||||
Output::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::{parse_input, Output};
|
|
||||||
|
|
||||||
const SAMPLE_INPUT: &str = r#""#;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), Output::default());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), Output::default());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), Output::default());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), Output::default());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
1000
day01/input.txt
1000
day01/input.txt
File diff suppressed because it is too large
Load diff
|
@ -1,92 +0,0 @@
|
||||||
pub const INPUT: &str = include_str!("./input.txt");
|
|
||||||
|
|
||||||
fn parse_input(input: &'static str) -> Vec<[u32; 2]> {
|
|
||||||
let input = input
|
|
||||||
.lines()
|
|
||||||
.map(|line| -> [u32; 2] {
|
|
||||||
let nums = line
|
|
||||||
.split_whitespace()
|
|
||||||
.map(|num| num.parse::<u32>().unwrap())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
[nums[0], nums[1]]
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
input
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let input = parse_input(INPUT);
|
|
||||||
let result_1 = part_1(&input);
|
|
||||||
println!("{result_1}");
|
|
||||||
let result_2 = part_2(&input);
|
|
||||||
println!("{result_2}");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_1(input: &Vec<[u32; 2]>) -> u32 {
|
|
||||||
let mut left = vec![];
|
|
||||||
let mut right = vec![];
|
|
||||||
for pair in input {
|
|
||||||
left.push(pair[0]);
|
|
||||||
right.push(pair[1]);
|
|
||||||
}
|
|
||||||
left.sort_unstable();
|
|
||||||
right.sort_unstable();
|
|
||||||
let mut diff = 0;
|
|
||||||
for i in 0..left.len() {
|
|
||||||
diff += u32::abs_diff(left[i], right[i]);
|
|
||||||
}
|
|
||||||
diff
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_2(input: &Vec<[u32; 2]>) -> u32 {
|
|
||||||
let mut left = vec![];
|
|
||||||
let mut right = vec![];
|
|
||||||
for pair in input {
|
|
||||||
left.push(pair[0]);
|
|
||||||
right.push(pair[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut result = 0;
|
|
||||||
|
|
||||||
for num in left {
|
|
||||||
result += num * right.iter().filter(|&&x| x == num).count() as u32;
|
|
||||||
}
|
|
||||||
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::parse_input;
|
|
||||||
|
|
||||||
const SAMPLE_INPUT: &str = r#"3 4
|
|
||||||
4 3
|
|
||||||
2 5
|
|
||||||
1 3
|
|
||||||
3 9
|
|
||||||
3 3"#;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), 11)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), 2192892);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), 31)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), 22962826);
|
|
||||||
}
|
|
||||||
}
|
|
1000
day02/input.txt
1000
day02/input.txt
File diff suppressed because it is too large
Load diff
|
@ -1,85 +0,0 @@
|
||||||
#![feature(array_windows)]
|
|
||||||
pub const INPUT: &str = include_str!("./input.txt");
|
|
||||||
|
|
||||||
fn parse_input(input: &'static str) -> Vec<Vec<i32>> {
|
|
||||||
let input = input
|
|
||||||
.lines()
|
|
||||||
.map(|line| -> Vec<i32> {
|
|
||||||
line.split_whitespace()
|
|
||||||
.map(|num| num.parse::<i32>().unwrap())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
input
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let input = parse_input(INPUT);
|
|
||||||
let result_1 = part_1(&input);
|
|
||||||
println!("{result_1}");
|
|
||||||
let result_2 = part_2(&input);
|
|
||||||
println!("{result_2}");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_safe(report: &Vec<i32>) -> bool {
|
|
||||||
let increasing = report[0] < report[1];
|
|
||||||
report.array_windows::<2>().all(|window| {
|
|
||||||
let increase = window[1] - window[0];
|
|
||||||
if increasing {
|
|
||||||
1 <= increase && increase <= 3
|
|
||||||
} else {
|
|
||||||
-1 >= increase && increase >= -3
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_1(input: &Vec<Vec<i32>>) -> usize {
|
|
||||||
input.iter().filter(|&report| is_safe(report)).count()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_2(input: &Vec<Vec<i32>>) -> usize {
|
|
||||||
input
|
|
||||||
.iter()
|
|
||||||
.filter(|report| {
|
|
||||||
(0..report.len())
|
|
||||||
.map(|i| [&report[..i], &report[i + 1..]].concat())
|
|
||||||
.any(|modified_report| is_safe(&modified_report))
|
|
||||||
})
|
|
||||||
.count()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::parse_input;
|
|
||||||
|
|
||||||
const SAMPLE_INPUT: &str = r#"7 6 4 2 1
|
|
||||||
1 2 7 8 9
|
|
||||||
9 7 6 2 1
|
|
||||||
1 3 2 4 5
|
|
||||||
8 6 4 4 1
|
|
||||||
1 3 6 7 9"#;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), 379);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), 430);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
~-mul(858,892)?@#mul(380,985)what()[^what()%mul(340,11)~*}don't())/~-mul(849,387)%-why()when():how()>-,what()mul(605,504)what()~:]what();how()who()];mul(771,783)?^ who()}~?>mul(111,830))@ ~mul(329,797)%'why()why()mul(125,409)-*/where()()@&!why()mul(390,37)when(974,538)#/when()){/don't()/mul(20,990)}?%{(who()mul(627,567)(how()'<(#%how()mul(387,315){;%who()%#from()mul(868,680)}^$mul(862,19)mul(847,689)>((#@when()}mul(339,156)+/{}@{^%[why(231,704)mul(236,754)]'^where(978,690)mul(460,872)#'*mul(518,944)>mul(301,886))mul(477,933)^mul(685,909)who())]what(288,791)mul(170,434){ &where()~(@where()mul(191,104)mul(637,600)&select()why())~select()mul(534,617)?mul(763,508){from()when(22,266)+who() when()mul(204,352)when()mul(426,122)-<*where()'$ why()mul(192,980)[(#[!$-}mul(798,208)''[!where()what()select()mul(295,727))#)}($<?<mul(452,502)(don't()mul(737,492)>,$%where(539,126)what()when()select()'@mul(311,541),?don't()#select()!}!(}&?mul(100,142)),-}%mul(222,856)~$;>!from()where()mul(758,901)mul(757,796)mul(976,686);@'~+-{#who()mul(26,971);mul(404,362)^~who(417,106)what()#mul(186,691)from() %#+{/mul(67,433)-who()!-+!mul(184,469)*when()[&when(458,221)<$mul(163,556)^)]?,'}&+who()mul(514,239)~)(mul(143,441)'how(741,776)~who(766,575)when();>*^mul(281,143)+!>;+:mul(767,44)#<mul(490,849)> when()why()don't()how()from()[from()from(){mul(436,519)what() *who();@{,>do()%'mul(19,540)when()mul(643,539)~when(812,543)mul(527,639)-!mul(409,379)where()/(mul(168,491)#$>]mul(432,333)@%<when();{?what()^mul(819,413)'where(65,845)}-' ^@don't()?how()when()>><mul(591,832)where(600,755)]who()}do()!^-$what()from()select()'#mul(572,956)@#:what()from(),]mul(303,346) when()$$how()@%/#$mul(857,344)/what()where()mul(969,234)$!#when()>>&who()(mul(113,494)%where()why()when()mul(659,592)<why()!<}mul(429,162)[who()*>#(/'mul(72,670)when()^^mul(369,596)mul(631,168)-why()()[*}mul(330,968) $why()where()mul(230,139)don't()@)@<mul(849,413)-when(){*?]mul(821,9)mul(753,277)]{&when()%:mul(262,360)what()mul(65,276)don't()])who();where()$!,(-mul(952,221)+:/{where()where()mul(608,843)'>where())%}where()&,}mul(875,661)~don't()':why(){mul(793*:mul(399,702)!://select()@when()why()do()@mul(488,581{?{&<who(617,140)@how()mul(156,982)why()'&<where()*:{mul(452{-+$$*/mul(202,724)]#:#why()+??(#mul(607,2)@^mul(20,845)#{+#[/#~/mul(111,872)how()select()]<how())'how()mul(921,254)$:;/where() ~why()}?mul(558,122)@how()<<who()mul(992,319)what(734,450)[^mul(498,490)/mul(632,639)when()]from(){why()]$[who(664,268)mul(401,695]!>how()&select()!<'mul(912,311)why()! })@+}mul(128*mul(626,752)%mul(49,60)[,who()what()select()<what()mul(24,8)>)@@]*]why(937,788)from():mul(945,658)<]don't()where()how(515,644)@+'select()how()mul(369,665)/],<when(){( $how()mul(361,594)$select()&:{:$when()mul(52,806) #from()@when()where():>mul(263,185)where()^why()why()@what()mul(82,407)mul(464,537)[mul(871,333)^mul(560,227)-why()mul(966,203)$what()+where()#mul(101,21)}%how(),)^who()>,select()mul(667,565)('what(),%select()(@mul(500,204:''<~'why(477,559)<do()>)[where()mul(698,648);how(){&?what()^@[%mul(280,395)>~, mul-#/%:where()>where():mul(170,746)don't()}($:@mul(998,876)*~<[mul(121,366)-?#;how()>from() ::mul(804,883)^-[ (:mul(100,354who(544,766)+,]>!['/;mul(949,115)
|
|
||||||
[^!})from()&mul(617,518)*how()(:@who()what()/mul(591,163):what()?{'do()!/when()!$mul(394,797)]how(620,741)!:!mul&%mul(523,862) ~}where()why()}from()! @do()mul(270,205)from()[&^mul(577,474)?{*/why()*what()mul(656,30)where()+#,@mul(295,616)why()/mul(8,267))-^when()who(610,661)'mul(182,139)select()}select()!when();;mul(492,992)?how()~($who(716,562)%/mul(702,654))*>mul(126,386)[mul(351,400)select()%$[!}{+mul(98,266)mul(924,5)*'(^:[}!?mul(112,163)+!?where()mul(987,791)mul(943,488)how()mul(698,312)&:@from(442,439)~%~:mul(235,520)%mul(248,221&>/;select()what()) ~@from()mul(546,261)'mul(956,953why(458,937)when()~!where();mul(442,916)%;)&(mul(410,237)where()~why()[+?[mul(169,337)what()who()&what()mul(901<where()#&who(808,156)-mul(322,634)>/mul* don't()mul(999,662)*]&/'#<+<select(621,69)do()>,^}'mul(365,260){{?,,}from(520,861)where()what()mul(325,208): when()+>{!;mul(335,726)#',:>@?mul(48,443![mul(130,626)!{</#%*select()mul(806,140)'']'~mul(697,649)&,+??[%?how()mul(515,385)mul(878,769)^when()&what()]:$)*%don't()#){/mul(119,439)-[,+!'don't()^<what()~^-[(-%mul(791,824)+>^don't()*?-*[%>mul(934,995),how()@from()'<mul(907,832)?% who()(*[do()%:where()what()>#mul(433,843)why()<}$}how()-mul(754,464)when()why()mul(992,113);]/{%mul(87,293^]how()why()~&when()*#mul(589,979)@-&select()/%mul(218,248);mul(536,581)when()mul(215,212)/%when(66,857)@what()+mul(958,271) '%#who()&{mul(239,197)}what()$>{*'select()mul(365,443)>why()how()what()%mul(885,496how()when()}{@/ mul(589,42)^:;who()where()why() !how()(mul(574,947)*;where():&where()%]<{mul(572,4)$mul(232,716)when()<?>when()mul(928,697)^(where()mul(301,501)-mul(100,436)#~?mul(708,770): @:@)!*mul(89,177)><where()]mul(699,985)(-)do()#who()mul(194,358)why():when()/why()where()mul(103,669)#mul(779,400)@when()~/;/({mul(760,763&-when()%]where()*#mul(781,829)*select()><@+ {when()+mul(926,998);>,)?,$)mul(813,382)}from(728,403)^mul(497,820)where()(?why(454,153)!select()}*!don't()what()from()}&}<?)([mul(379,305)!when(): don't() ~~why()@&%mul(953,224))![*)/mul(802,693):;mul(126,477)-when(409,550){mul(238,713)!/!why()-}+>?how()mul(432,895)$!+mul(743,149)$!why(704,998)when()mul(229,683)((when()from()#&{mul(217,869)^)?)?what() select()}mul(765,209)who():}%{mul(448,553)[:-,don't()what()<,}from()where())mul(543,719)from(415,153)why()!'?^~mul(666,540)mul(922,877)mul(416,636)+#;$select()'mul(971,485)from(964,539)where()^ *who()/mul(35,594)<:mul(207,585)~*}'<when()>[]#mul(815,776){?%&*@?mul(385,133)['!:who() )mul(439,846)&)mul(529;?>;#mul(677,906)^& ()mul(75])how())mul(481,206)who()why()$^ from();what()'why()do()(%^&)mul(277,454)>where()where()$-#select()+/don't()what()select()]mul(295,126)why();from()mul(203,301){#mul(572,420){%(-*mul(929,786)do()mul(107,813)mul(921,668)'^+++!:[;mul(587,921)mul(242,920)mul(933,463)why()mul(340,196)'--']-mul(623,675)select()what()mul(656,927)<$)from()where(473,933)]~mul(408,566)!>$mul(373,541)}%*^)mul(346,14)>&how()@^-(&;mul(993,735)select()*{mul(990,221)*from():[ mul(940,96)/how()^>#;select()/#?mul(624,249)>mul(160,974)]^mul(589,900)&$[?[<-!select()mul(512,717)^/&mul(226,478)* ';'+from()?@~mul(224,929)!when()^what()where()'@'>~mul(451,87)
|
|
||||||
when()%how()where()how()what() mul(59,36)how()where() )><when()[(mul(776,247)when()# &why())}?mul(331,460)]how()/why(382,926)&*mul(494,482)'*;~#/select()?who(828,76)mul(205,327)~:how(),^how()why()mul(466,546)+'~&mul(481,829?who()!{+who()from()^(%>mul(270,950)--mul(864,193)$!!from()[+when()do()?&]from(){?who()mul(576,443)}>*what()mul(60,617)]where(){*}what(16,936)*:mul(613,575) @$%%'mul(930,241)!~when()<+what()&{mul(189,41)don't()how()%who()how()mul(79,681){']{({ mul(615,354)~#&{mul(863,397)<?;how()mul(264,31>@?(mul(469,991)!mul(97,649)'%{where()/{+*}when()mul(429,913)[ >where()>](when(654,639)),mul(763,148):!~do()%+*',mul(646,831)~*$!?>mul(632 @?from()[mul(165,564)#mul(464,289)from(),mul(197,442)~[&mul(739,935)how()where()!],mul(583,831){mul(4,501)mul(912,584):select()(when()>&& &what()mul(836,498)where(987,400)*${mul(983,648)+~]don't()&,how()'^[*({mul(180,898)mul(982,907): select()($what()mul(294,259)do()where();>mul(130,154)mul(566,682)how()-:from()/ )^mul(50,250)~@select()(->mul(65,434)mul(865,288)+$don't()#+-<when()mul(348,972)#{^*<who()&,mul(545,238)select()mul(736,427)$from()mul(24,605)select():mul(183,229) do()-$where()$where()how()#[why(){mul(440,221)?when(171,776)$mul(930,461)?mul(118,801)how(162,609)where()'why()@ ;:$mul(538,213)>mul(875,123)@@>?mul(606,377);do();!where(){mul(267,543):]','# #*why()mul(31,575)#;who() *<$mul(797,419)'what()}when():what()/mul(627,73)'how(218,429)who()]*$,$from()mul(221,471)$ ;what()mul(38,106)?-&!~&from()mul(117,669):how()mul(422,348)(:/]mul(568,980)when(){~where(490,375)<(& mul'*)'where();##:}mul(34,144)mul(352,352) select()-when()/where(365,161)mul(571,634)mul(373,66)}how()don't()where()@>$$(!&mul(532,260))!mul(304,873)select(676,286)?#<,why(),<!do()/what()]?~^where(558,20)mul(744,233)^''mul(119[/%where()why()%who()mul(797,726)~*why()mul(743,436)?/-why()mul(399,351)mul(398,28))what()(when()/$what(169,128)>^~do()%@~where()mul(56&+select()>select()what()mul(670,288)< $:+<mul(706,866),)when()when()from()mul(391,781)~mul(142,120)>[$~what(){@!%mul(422,126)(who()?from()}*}mul(459,923)mul(38,243)^)!who()::#from()/mul(845,589)^/when()'#when()~,'select()mul(454,166)who()~>when()^when()?'@where()mul(237,855)~from()from()why()mul(233,606)]@mul(947,750)!@*}who()(@%mul(252,951)[from(995,363))}),when()who()+where()mul(368,442)>from()where()select()from()what()^?mul(190,689)mul(337#who()*when()/*mul(652,631);,*why()+select()>}where()%mul(839,296)>&%,@}$mul(723,530)who(685,511) %~where(782,449)mul(36,917);]]{mul@where()!&*%why()mul(191,759):why()what()$mul(900,773):$who() *{mul(426,740) why(396,306)/from()why()*%}'+do()@!'how()%^/mul(970,462)when()who()!-mul(535,35)}from(377,342)when()/(how()who()-}:mul-what()/how()?*^how()mul(217,447)/]?%!mul(495,690)}#<{?,do()+-why()<mul(613,900)<@when()@)from()mul(590,34)-why()mul(524,292)>mul(3,559)who()+what()mul(942,139)})when()who()<-]'what()what()mul(218,316)how()mul(669,389),<+mul(861,165)why(){^}[mul(594,386what()who(){mul(801,662)mul(852,2)-mul(458,479)//mul{don't()mul(826,480)>mul(954,968)$;mul(871,184)from()select()**<]!mul(503,290)#select()where()?do()mul(154%[&how()?mul(279,673)-[don't()$]why()-what(754,13)mul(841,495)where()}{mul<-'##!/usr/bin/perl@~mul?what()<^-@/>from()!mul(573,383)where()-{#mul(420,579)when(977,697)when() &@##from()+}mul(314,487)
|
|
||||||
who()+from()where()mul(878,982)]~mul(812,80)?select()don't()how()];mul(986,548)/how(311,658)/select()(don't()(select()select(533,328)<^+from()what()why()@mul(786,152)*<[ }},)mul(30,285)mul(721,12)#(-{what()mul(70,496)^when()-/how(420,87)select()what()]$mul(645,406);-~where()>do()~&^(,}$#$mul(993,357)?/select()}do()+from()~@mul(661,590))what()*!?]*!'mul(19,345)-why())select(){%(% don't():*#when()~select()mul(910,416)}mul(550,400)<from();/)$who()mul(107,198)*^;what()*mul(585,659)]}<*[mul(408,612)(how()+'[don't()select()mul(910,993)({[who(895,379)>when()]~mul(515,93)&where()mul(412,99);(;+mul(611,500%what()%,from()when()mul(822,769),-*(([$(mul(153,856)why(){mul(476,25)do()-mul?from()<<[why()&mul(859,60)what()]+ :how()what(434,726):^from()do()}*?}?mul(432,641)>%<why();where()mul(722,325)who()why()do()'$,>?!mul(93,484)++}?mulwho()#>who()select(): why()mul(889,212)>]?where()&mul(808,71)<*/'-+select()mul(523,619)+#where()mul(324,306)why()';why()}mul(337,315)~:what():^?-$from()mul(924,137)mul(444,59)why()[from()how()who()mul/how()>mul(304,707)'select() select()mul(224,915)mul(991,306)[>$! &how()>/mul(719,679)how()select()mul(65,620)from()#'~:]<mul(906,303)}what():how()&%^select():{mul(644,751),^,&,!*'@mul(323,720)why()>+-from()]mul(971,857)how()#[~~]?%mul(230,961)from()from())# } where()mul(330,14)>mul(411,981)}}<)mul(304,453)how()from()$who()mul(573,848)% ;:<mul(23,887)>from()(~select()!mul(542,790)}'#mul(530,502)%$(-#$mul(358,540)mul(10,361)when()where()<}&where()mul(429+!*$~)mul(446,812)%when()don't()>~>^what()select()why()from()where()mul(330,214) -[mul(731,164)/mul(776,235)mul(240,20)who()^what()']@!-who()%don't()(( )'!how()why();>mul(941,911)'?where()from()how()/mul(489,746(select(725,995)-from()?;when()%]%<mul(293,629){;what();(~!<mul(176,456)<~who(252,77)who()~{why()?]&mul(587,279){%?]from()<?mul(313,626)@[/how()+&don't()mul(298,798@!'&when()~(#[mul(827,523)from()$ where()who()%mul(54,803))*mulselect()%mul(500,731)mul(946,993&;{/;where()^where()mul(795,350)where(),~ @^how()-]mul(995,399)%who()do()where()mul(911,909$(?!$]]~what()mul(151,846)[select(636,807)mul(111,19)where(){^mul(730,317)who()^do()'~#]$/$@<>mul(555,315),how()#%!><from();mul(845,939)>?mul(664,596how()+'-who()from(51,408)mul(605,672)?!%from()) #}don't():}mul(579where()mul(243,699)mul(321,902)*!/mul(465,704)*when()[*how()mul-!mul(15,80)}#}mul(413,156)(;mul(71,288)/$;'don't(),how()+[;$who()%$when()mul(516,863)mul(268,600)(</from()~how()'<how()where()mul(715,920)&,mul(989,598)[~where()where()mul(635,110);from()*mul(843,35)&*}@[how(232,546)'-+ mul(979,532)[do()&mul(649,85)]how(832,401)-;mul(876,724)-[mul(432,417)!from()select()]mul(967,886'mul(561,191)#mul(660,865)-}~#mul(736$mul(623,276)from(93,634)^<&-+!@(how()mul(543,427)]#what()from()mul(247,751))from()where()+/^@!;?mul(919,365)where()]&!{-:~why()mul(220,330):]&mul(919,207)-&who()?*how()#%mul(759,323)!how()how()mul(695,755)[{mul(426,127)-{% /~mul '*&how()who()^(mul(797,201)'mul(509from()when()(@(<()don't() :&mul(852,261)<#^]from()mul(981,414)(</who()*do()(+where()*'why()what(229,53)+mul(954,398)mul(148,957)what()^&*mul(92,295)select(){mul(146,508) who()}[>mul(602,939)who())>)<&'!mul(323,967)?mul(673,398)):&#}>>{!mul(501,484)<;who(969,453)-who(624,921)-)<-mul(72{-//!mul(576,751)mul(318,331)mul(707,186)+how()mul(660#how()!+#?where()mul(547,453)
|
|
||||||
[what()?->+[mul(266,969)what()from()%^!how()?mul(236,335) )'<>,&!-where()mul(563-select()(mul(405,969)when()[%;why():$]mul(266,763)what()~#-<how()?mul(574,316))^;//}:when()}}mul(798,955)%?(%}*>{+don't()~+-mul(68,150)#{{?%:mul(422,966)select()mul(143,33);mul(917,142))]'>mul(23,457);'what()why()-where()}/>mul(66,911)&&':(>why()>mul(413,27)mul(772,64)mul(266,512)%$<what()who()*-)mul(169,905))where()do()~where(),how()^:what()mul(584,453{#&&:how():,how():%mul(937,5)mul(974+:when()where()~}+-<mul(356,901)~?]when()select()mul(933,555)&'-mul(728,399){&>*[why()<mul(862,418)?>:where(),@%^',mul(750,295)*]:<mul(491,8)#^&mul(801,442)where()where()@/how()+where(17,463)(select()mul(460,732)*what()}/-})>mul(17,60)!!}*from(975,930)mul(763,134)mul(463,381)when()(select()where()+{?what()mul(755,843)!why()+>mul(24,584){mul(105,734)$why()@where()!+what()%what()mul(5,111)#^;?{^/?^~mul(24@>when()what()where()#from(284,9)when(437,59)mul(978,337))+:(select()mul(996,373)(what(188,513)@ ]from()}mul(370,765)~$mul(490,904))]/%who()why()/mul(123,978how()why()[who()~%how(180,982)<mul(251,677)!%(>@:mul(343,157)![/*^mul(157,976)who()from() select()]+?+do();)&)<from()!/select()mul(143,894)]<*,?mul(900,759)]:%@:mul(496,2)*don't())-$# ?!>mul(734,420)$%(select()>'mul(143]mul(4,351)mul(279,828)'}^mul(108,132) #how()why()}mul(573,602)}@mul(747,126)where()'@mul(247>why())when()+::^&from()mul(843,212)^mul(612,743)[mul(204,899)$mul(174,265)%]mul(864,804)-from()how()%%mul(674,431)^^#[(@:&*mul(619,935)select()//~^mul(70,941)why()select(405,825)why()who()@mul(112,658)'+(@!$who(){select()do()from()from()@how(846,925)mul(417,888)~{: who()&-;mul(285,186)-+what(){/+-mul(24,944''mul(935,370)why()?~ +mul(468,38)'why()(/mul(704,512)%mul(946,591,<);from()select(290,495)*{:<do(),)/mul(522,493)(^mul(182,31)/mul(330,74);'%:mul(793,487)-;where()who(){where(590,54)(mulwhen()@ :]!mul(812,795)(:mul(468,59-(how())where()',;mul(263,506);^why()mul(159,826)(,: /$mul(179,478)[,(who()>['%mul(554,965)<why(920,323)mul(3,344)do()]why()mul(353,389)' )+)%from()do()select()#>(~mul(308,534)mul(6,373)^how()@%&how()~mul(669,386)when() 'mul(33,652)mul(950,268)::mul(98,181)]^how()'!mul(982,613)how()&where()]what()how()do()[from()#[? mul(929,452)<$$<who();^]don't()&what()-]}<&from(),~mul(721,96)$}^[what(272,30)&who()mul(107,629)why()why()where()-how()/}from()+mul(718,337) *mul(49,736)why()&/'where(888,569)#&where()]+mul(728,703)!'> mul(506,408)-mul(670,674)how()mul(645,104)do()(>[%from()@'who()&%mul(45,884)mul(895,714)mul(871,6)},?&;!select()#where(779,295)^mul(113,370)why())%[select()[,^' mul(976,960)][%mul(828,993){}}mul(135,443)>what()mul(344,20)>where()/) :@mul(564,715){([,]'mul(675,478)#*@who()>]$*+mul(94,992}<mul(565,578)/mul(85,827)mul(565%do()/+{[mul(956,611)what()mul(807,414)]what()how(521,834)]where()}>from()mul(288,445)mul(72,57)*/})how()[how()!mul(543**%who():what()mul(345,778){mul(462,244)from()[@*who(),+mul(591,870)#select()%mul(779,654)$+%%@ mul(920,934)?-select()-}mul(247,709)@$why()mul(179,824)(when(989,252)?mul(422,816)$[from()#who()<mul(672,845)mul(118,135)
|
|
||||||
*what()}[*how()?why()mul(386,104)[from()];mul(208,918))){(+<how(),:how()mul(694,384)@!-*{mul(69,248)?',what(), ^<;mul(902,984)*mul(369,924)^?^mul(594,537)>@,when(),mul(922,47)@mulwhy()-mul(890,397)-^/+'select()[&!who()mul(547,6)-]>:^;mul(870,938),~?[%mul(8,689!>*@!]mul(311,244)->how()$when()'}mul(213,766)$:!+ mul(620,644)%where()mul(430,127)%{[mul(682,585)mul(245,26)don't()mul(510,688)where()]-mul(844,443)/@+who()?who()when()mul(453,182)mul(928,131)<select()who()(]mul(422,986)[&&who()[how()$mul(54,860)!]{;mul(549,103)<%;mul(807,173)/mul(513,515)@mul(852,657)'#when(293,457)$&+why()mul(694,888)*why()mul(912,542)$$!:$mul(776,404^$$}&(mul(965,836)-what()*:]mul(97,471)/*~]what(){[what()mul(241,843)where()[^mul(639,208'}(- who()how()mul(869,533)how()who()what()select()%don't() where()(why(811,325)!<where()^~;mul(955,806)][)])+,% mul(207,798):&who(),<where() how()mul(857,424::,]mul(250,416)select()'{mul(815,806)[)/@mul(285,41)$mul(901,755)from()!)?why()){!mul(78>?&'{[+@?,mul(55,18)mul(795,739):}what())@$]'mul(377,34)&,~*why()<do()<mul(795,39)where()$%+?>/@who()mul(467,127))&how(28,925)mul(955,519)}where(830,382)$when()[-why()/+mul(310,139)mul(217,931)!mul(574,122)!mul(227,82)where()mul(940,851) {mul(545,758)<select()?[mul(720,337)mul(52,940)~how()from(855,795)*mul(664,962)>:from()%~/mul(937,897)mul(665,919)^&/ &what()mul(23,37),select()%*mul(98,952);mul(171,967)who()$+]when()%$mul(426,870)<<;;why()[do()@mul(28,286)-what()([+select()why()do()<^+what()^?~-mul(246,992)/mul(938,936)'$>when()mul(18,736)%?how()-what()from() <do()mul(994,498);<,how(800,873)[%/&mul(260,162)why()]when())(what()}#don't() mul(99,24)(*!@]]mul(490,150)~mul(47,794)$#}where()(who(){what():mul(369,830)mul(24,75)where():(,@)]$~mul(509,783)mul(914,160)+mul(619,799)&@~how()from()mul(445,64)*>when()select()mul(37,387)}<[}?+how()#&?mul(779,369)select()mul(750,510)%[,'from()>who()mul(13,97)what(547,477)why(859,962)?,where()mul(806,879)mul(577,179)#from()+>where(705,292)what(712,121))when(227,970)*mul(942,336)& who())!<mul(345,567)/-select(838,572)-~'*)why()[mul(12,866)@^where()?<mul(985,870)where(503,821);^mul(803,551)'[%#where()-who())mul(38,22)^}$who()?,how()%what(528,476)who()mul(486,865)<(/mul(714,503)%%,$select()]mul(299,58)-when()~why()-}mul(684,388) /^<:[;:don't()why()who()<who()-{mul(413,975),>*mul(992,750):from()<:+-mul(938,672)mul(55,872)mul(354,183)>+(+mul(520,932)#from():}{who()$mul(675,973)@^@%mul(58,468)/select()what()->]mul(343,375)^ ,%mul(480,300)where()(/*$mul(695,676)how()where(),-!:from()mul(363,212)~(!where()-[what()don't()mul(614,594))mul(569,802)'mul(995,471)~&$:^:how()how()-^mul(853,428)-;-%what()(from()+do()'where()() !{^?#mul(376,780)select())where()select()&{-,{,mul(894,646)select()*< @}*[}}mul(332,665)[
|
|
107
day03/main.rs
107
day03/main.rs
|
@ -1,107 +0,0 @@
|
||||||
#![feature(array_windows)]
|
|
||||||
|
|
||||||
use regex_lite::Regex;
|
|
||||||
|
|
||||||
pub const INPUT: &str = include_str!("./input.txt");
|
|
||||||
|
|
||||||
type Input = &'static str;
|
|
||||||
|
|
||||||
fn parse_input(input: &'static str) -> Input {
|
|
||||||
input
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let input = parse_input(INPUT);
|
|
||||||
println!("Part 1: {}", part_1(&input));
|
|
||||||
println!("Part 2: {}", part_2(&input));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_1(input: &Input) -> usize {
|
|
||||||
const PATTERN: &str = r"mul\((\d{1,3})\,(\d{1,3})\)";
|
|
||||||
let regex = Regex::new(PATTERN).expect("I fucked up the regex");
|
|
||||||
assert!(regex.is_match(INPUT));
|
|
||||||
|
|
||||||
let mut sum = 0;
|
|
||||||
for r#match in regex.captures_iter(input) {
|
|
||||||
let first = r#match
|
|
||||||
.get(1)
|
|
||||||
.expect("Missing first number")
|
|
||||||
.as_str()
|
|
||||||
.parse::<usize>()
|
|
||||||
.expect("Failed to parse first number:");
|
|
||||||
let second = r#match
|
|
||||||
.get(2)
|
|
||||||
.expect("Missing second number")
|
|
||||||
.as_str()
|
|
||||||
.parse::<usize>()
|
|
||||||
.expect("Failed to parse second number:");
|
|
||||||
sum += first * second;
|
|
||||||
}
|
|
||||||
sum
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_2(input: &Input) -> usize {
|
|
||||||
const PATTERN: &str = r"mul\((\d{1,3})\,(\d{1,3})\)|do\(\)|don't\(\)";
|
|
||||||
let regex = Regex::new(PATTERN).expect("I fucked up the regex");
|
|
||||||
assert!(regex.is_match(INPUT));
|
|
||||||
|
|
||||||
let mut sum = 0;
|
|
||||||
let mut enabled = true;
|
|
||||||
for r#match in regex.captures_iter(input) {
|
|
||||||
match r#match.get(0).unwrap().as_str() {
|
|
||||||
"do()" => enabled = true,
|
|
||||||
"don't()" => enabled = false,
|
|
||||||
_ if enabled => {
|
|
||||||
let first = r#match
|
|
||||||
.get(1)
|
|
||||||
.expect("Missing first number")
|
|
||||||
.as_str()
|
|
||||||
.parse::<usize>()
|
|
||||||
.expect("Failed to parse first number:");
|
|
||||||
let second = r#match
|
|
||||||
.get(2)
|
|
||||||
.expect("Missing second number")
|
|
||||||
.as_str()
|
|
||||||
.parse::<usize>()
|
|
||||||
.expect("Failed to parse second number:");
|
|
||||||
sum += first * second;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sum
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::parse_input;
|
|
||||||
|
|
||||||
const SAMPLE_INPUT_1: &str =
|
|
||||||
r#"xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))"#;
|
|
||||||
const SAMPLE_INPUT_2: &str =
|
|
||||||
r#"xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))"#;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT_1);
|
|
||||||
assert_eq!(super::part_1(&input), 161)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), 173529487);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT_2);
|
|
||||||
assert_eq!(super::part_2(&input), 48)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), 99532691);
|
|
||||||
}
|
|
||||||
}
|
|
140
day04/input.txt
140
day04/input.txt
|
@ -1,140 +0,0 @@
|
||||||
SASASMSSSMSMSMSMSSMSAMXMAMAMXSXXXMAMMXSAMXMXMXSMMMXXXSXXAXSMMMAMXAXSMSSXXMSASASMXSSMSMSXMMMAMMMXXSAMXSSMXAXSASMMMXMASAXSXMXMAMXAMXXMAXXAMAMX
|
|
||||||
AASAXAAAAXXASASMXSAXAMXXSMSSMSAXSMSMMASAMAAXMAMAAAMMMMMSMXSAMXSSMSMXMAXMASXAXAMXAAXMAMXAMASAMAAMXMASAMAAMSMSASASMMMMAMSXSMASMMSMSMMASMMMSAMA
|
|
||||||
MXMXMMMSMMMMMAMXAMXMSSSMAXAAXMAMAAAXMASASMSXMASMMXSAAAAAMAXAMAXAAXAAMXMAMXMSMSMMXMASMSMXSASAXXXSASXMASXMMXAMMMAMMAXMXMMAXXAMAAAAAAMAMAAXSAMA
|
|
||||||
XSMSAXMAMAAXMAMMSSXSAAXSMMXXMASMMSMSMXSMMAMMSMAAXASMSMSSSMSSMMSMMMSSSSSSSMAMAAXMXXXAAAAAMMSAM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MXMMSAXAXAASAMXMAASXMMMXSAMMMAXXAAMASAMXXAAASMMSXSASMMAXAAMMMAMMAMMAMAAXASXSAMXAMMMMMSMSMMMMXMMAAXSMSAMXMSMMSAMXXMAMXXMASXMXSXMSA
|
|
||||||
MMMMMXMAXAMXMSASMMMXMMSMMAXXMMAAXAAMAMMXMMSSMSASAMMSMSMSAAAXSAMAMAXSMMXSAMXAXMAMXMSASAMXMMASAAAAAXAXAXMASMSMMSXSMMXMXXXMASXMXMSXSMASASAXMXXM
|
|
||||||
MSAAXSMMSAMAMMAMXAMAXASAMMXSAMSMMXMSSXSASMMAAMXMAMAAAMXMMMSMMAMSMSXMASXSASMMXSASMXMAXMAMXMASMSMSSSMXSASASXMAXXMXMXMASXSMAMAXMASAAMXMMMAMSMAX
|
|
||||||
SSMSXSAAXXMASXSXSASMSASAMAAMAMMMSXXXAASAMXMSMMSSMMXSAMAXSAMXMMMXAXASAMAMXMAMAMMMAXMAMMAMAMMSAXXMMXXAXXMAMXMSSSMSXXAAXXXMASXMASMMMSSMXMSAASXM
|
|
||||||
XXAAMMMMSMSASAXAMAAXMASAMMSSMMMAMAMMMMMAMXAMXAAAAAMMAMXXMASXMMSMXMASAMXMASMMMSSSSSMAMSASXSSMMMASASASMSMSMSAAAAAMMMMMSMMMASAMSXAXAAXMAAXSMSXM
|
|
||||||
MMMMAAAXAMMASMMXMSMSAMXXXXAAASMAMXMASXSSMMSMMMSSMMMSAMSXSAMXAAAAASXSAMXSASAAXAAAAAXAMSAMAMXAMSXMASAMSXAAAMMMSMMMAAAXXMASXSMMASMMMSASMSMAXMMS
|
|
||||||
XMMXSMSMMSMAMXXXXXMAMSAMXMSSMMSMSASMSXXAXAXXMAXXMSAMXXXXMASAMSMSAMXSXMAMXSXMMMSMSMMMMMAMAMSSMMMMAMAMAMSMXMXXMXMASMMSAMXAASAMXSXXXXMXAMMAMXSX
|
|
133
day04/main.rs
133
day04/main.rs
|
@ -1,133 +0,0 @@
|
||||||
pub const INPUT: &str = include_str!("./input.txt");
|
|
||||||
|
|
||||||
type Input = &'static str;
|
|
||||||
type Output = usize;
|
|
||||||
|
|
||||||
fn parse_input(input: &'static str) -> Input {
|
|
||||||
input
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
|
||||||
let input = parse_input(INPUT);
|
|
||||||
println!("Part 1: {}", part_1(&input));
|
|
||||||
println!("Part 2: {}", part_2(&input));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_1(input: &Input) -> Output {
|
|
||||||
let horizontal = input.match_indices("XMAS").count();
|
|
||||||
let horizontal_reverse = input.match_indices("SAMX").count();
|
|
||||||
|
|
||||||
let grid = input
|
|
||||||
.lines()
|
|
||||||
.map(str::chars)
|
|
||||||
.map(Iterator::collect::<Vec<_>>)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let grid_size = grid.len();
|
|
||||||
let mut vertical = 0;
|
|
||||||
let mut vertical_reverse = 0;
|
|
||||||
for i in 0..grid.len() {
|
|
||||||
let column = grid
|
|
||||||
.iter()
|
|
||||||
.map(|line| line.iter().skip(i).next().unwrap())
|
|
||||||
.collect::<String>();
|
|
||||||
vertical += column.match_indices("XMAS").count();
|
|
||||||
vertical_reverse += column.match_indices("SAMX").count();
|
|
||||||
}
|
|
||||||
let mut diagonal_nw_se = 0;
|
|
||||||
let mut diagonal_ne_sw = 0;
|
|
||||||
for y in 0..=(grid_size - "XMAS".len()) {
|
|
||||||
for x in 0..=(grid_size - "XMAS".len()) {
|
|
||||||
let chars = [
|
|
||||||
grid[y + 0][x + 0],
|
|
||||||
grid[y + 1][x + 1],
|
|
||||||
grid[y + 2][x + 2],
|
|
||||||
grid[y + 3][x + 3],
|
|
||||||
];
|
|
||||||
if chars == ['X', 'M', 'A', 'S'] || chars == ['S', 'A', 'M', 'X'] {
|
|
||||||
diagonal_nw_se += 1;
|
|
||||||
}
|
|
||||||
let reverse_chars = [
|
|
||||||
grid[y + 0][x + 3],
|
|
||||||
grid[y + 1][x + 2],
|
|
||||||
grid[y + 2][x + 1],
|
|
||||||
grid[y + 3][x + 0],
|
|
||||||
];
|
|
||||||
if reverse_chars == ['X', 'M', 'A', 'S'] || reverse_chars == ['S', 'A', 'M', 'X'] {
|
|
||||||
diagonal_ne_sw += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
horizontal + horizontal_reverse + vertical + vertical_reverse + diagonal_nw_se + diagonal_ne_sw
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part_2(input: &Input) -> Output {
|
|
||||||
let grid = input
|
|
||||||
.lines()
|
|
||||||
.map(str::chars)
|
|
||||||
.map(Iterator::collect::<Vec<_>>)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let grid_size = grid.len();
|
|
||||||
|
|
||||||
let mut count = 0;
|
|
||||||
for y in 1..grid_size - 1 {
|
|
||||||
for x in 1..grid_size - 1 {
|
|
||||||
if grid[y][x] != 'A' {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let chars = [
|
|
||||||
grid[y - 1][x - 1],
|
|
||||||
grid[y + 1][x + 1],
|
|
||||||
grid[y - 1][x + 1],
|
|
||||||
grid[y + 1][x - 1],
|
|
||||||
];
|
|
||||||
if matches!((chars[0], chars[1]), ('S', 'M') | ('M', 'S'))
|
|
||||||
&& matches!((chars[2], chars[3]), ('S', 'M') | ('M', 'S'))
|
|
||||||
{
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
count
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::parse_input;
|
|
||||||
|
|
||||||
const SAMPLE_INPUT: &str = r#"MMMSXXMASM
|
|
||||||
MSAMXMSMSA
|
|
||||||
AMXSXMAAMM
|
|
||||||
MSAMASMSMX
|
|
||||||
XMASAMXAMM
|
|
||||||
XXAMMXXAMA
|
|
||||||
SMSMSASXSS
|
|
||||||
SAXAMASAAA
|
|
||||||
MAMMMXMMMM
|
|
||||||
MXMXAXMASX"#;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), 18);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_1_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_1(&input), 2562);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_sample_solution() {
|
|
||||||
let input = parse_input(SAMPLE_INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part_2_with_solution() {
|
|
||||||
let input = parse_input(super::INPUT);
|
|
||||||
assert_eq!(super::part_2(&input), 1902);
|
|
||||||
}
|
|
||||||
}
|
|
87
flake.lock
87
flake.lock
|
@ -1,87 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"fenix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1732689334,
|
|
||||||
"narHash": "sha256-yKI1KiZ0+bvDvfPTQ1ZT3oP/nIu3jPYm4dnbRd6hYg4=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"rev": "a8a983027ca02b363dfc82fbe3f7d9548a8d3dce",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1732837521,
|
|
||||||
"narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"fenix": "fenix",
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"treefmt-nix": "treefmt-nix"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rust-analyzer-src": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1732633904,
|
|
||||||
"narHash": "sha256-7VKcoLug9nbAN2txqVksWHHJplqK9Ou8dXjIZAIYSGc=",
|
|
||||||
"owner": "rust-lang",
|
|
||||||
"repo": "rust-analyzer",
|
|
||||||
"rev": "8d5e91c94f80c257ce6dbdfba7bd63a5e8a03fa6",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "rust-lang",
|
|
||||||
"ref": "nightly",
|
|
||||||
"repo": "rust-analyzer",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"treefmt-nix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1732894027,
|
|
||||||
"narHash": "sha256-2qbdorpq0TXHBWbVXaTqKoikN4bqAtAplTwGuII+oAc=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt-nix",
|
|
||||||
"rev": "6209c381904cab55796c5d7350e89681d3b2a8ef",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt-nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
72
flake.nix
72
flake.nix
|
@ -1,72 +0,0 @@
|
||||||
{
|
|
||||||
description = "A Nix-flake-based Rust development environment";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
||||||
|
|
||||||
treefmt-nix = {
|
|
||||||
url = "github:numtide/treefmt-nix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
fenix = {
|
|
||||||
url = "github:nix-community/fenix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs =
|
|
||||||
{
|
|
||||||
self,
|
|
||||||
nixpkgs,
|
|
||||||
treefmt-nix,
|
|
||||||
fenix,
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
supportedSystems = [
|
|
||||||
"x86_64-linux"
|
|
||||||
"aarch64-linux"
|
|
||||||
"x86_64-darwin"
|
|
||||||
"aarch64-darwin"
|
|
||||||
];
|
|
||||||
forEachSupportedSystem =
|
|
||||||
f:
|
|
||||||
nixpkgs.lib.genAttrs supportedSystems (
|
|
||||||
system:
|
|
||||||
f (
|
|
||||||
let
|
|
||||||
pkgs = import nixpkgs { inherit system; };
|
|
||||||
fenix' = (import fenix { inherit system pkgs; });
|
|
||||||
toolchain = fenix'.minimal;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit pkgs toolchain;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
formatter = forEachSupportedSystem (
|
|
||||||
{ pkgs, ... }: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build.wrapper
|
|
||||||
);
|
|
||||||
devShells = forEachSupportedSystem (
|
|
||||||
{ pkgs, toolchain }:
|
|
||||||
{
|
|
||||||
default = pkgs.mkShell {
|
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
|
||||||
pkgs.openssl
|
|
||||||
];
|
|
||||||
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
|
||||||
packages =
|
|
||||||
[
|
|
||||||
pkgs.pkg-config
|
|
||||||
]
|
|
||||||
++ [
|
|
||||||
toolchain.cargo
|
|
||||||
toolchain.rustc
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
use std::{env, error::Error, fs};
|
|
||||||
|
|
||||||
use reqwest::blocking::Client;
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
|
||||||
let session = env!("SESSION");
|
|
||||||
|
|
||||||
let args: Vec<_> = env::args().collect();
|
|
||||||
let day = args[1].parse::<u8>()?;
|
|
||||||
|
|
||||||
let client = Client::builder().build()?;
|
|
||||||
let request = client
|
|
||||||
.get(format!("https://adventofcode.com/2024/day/{day}/input"))
|
|
||||||
.header("Cookie", format!("session={session}"))
|
|
||||||
.build()?;
|
|
||||||
let input = client.execute(request)?.text()?;
|
|
||||||
fs::create_dir_all(format!("day{day:02}/"))?;
|
|
||||||
fs::write(format!("day{day:02}/input.txt"), input)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
projectRootFile = "flake.nix";
|
|
||||||
programs = {
|
|
||||||
nixfmt.enable = true;
|
|
||||||
rustfmt.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue