1
0
mirror of https://github.com/chylex/Advent-of-Code.git synced 2025-09-15 15:32:11 +02:00

Compare commits

...

25 Commits

Author SHA1 Message Date
04e2c35138 Add 2022 - Day 8 - Part 2 2022-12-27 13:50:18 +01:00
c83c50eeaf Add 2022 - Day 8 - Part 1 2022-12-26 14:00:21 +01:00
c90b93c155 Add 2022 - Day 7 - Part 2 2022-12-26 11:06:51 +01:00
2456d3d7a0 Add 2022 - Day 7 - Part 1 2022-12-26 11:02:07 +01:00
20f7f156e0 Add 2022 - Day 6 - Part 2 2022-12-26 07:59:39 +01:00
cb9a50198d Add 2022 - Day 6 - Part 1 2022-12-26 07:56:55 +01:00
638c5c88b6 Add 2022 - Day 5 - Part 2 2022-12-14 10:45:13 +01:00
94bfc58598 Add 2022 - Day 5 - Part 1 2022-12-12 23:08:42 +01:00
ca7b829db3 Add 2022 - Day 4 - Part 2 2022-12-12 22:31:47 +01:00
4304efd023 Add 2022 - Day 4 - Part 1 2022-12-12 22:24:51 +01:00
c2b2da271b Refactor 2017 code 2022-12-05 03:21:16 +01:00
dbd9e028e6 Add 2017 - Day 2 - Part 2 2022-12-04 16:40:45 +01:00
7bd6da2c29 Add 2017 - Day 2 - Part 1 2022-12-04 16:26:33 +01:00
5bb9f0af43 Add 2017 - Day 1 - Part 2 2022-12-04 15:54:05 +01:00
dff04944f6 Add 2017 - Day 1 - Part 1 2022-12-04 15:52:40 +01:00
0d85994dc4 Add folder for PostgreSQL scripts for 2017 & update README 2022-12-04 15:45:52 +01:00
c81f9a4d99 Add 2022 - Day 3 - Part 2 2022-12-04 02:43:30 +01:00
eba4d3ff3e Add 2022 - Day 3 - Part 1 2022-12-03 18:25:35 +01:00
db090e6176 Add 2022 - Day 2 - Part 2 2022-12-03 16:08:52 +01:00
84975e8708 Add 2022 - Day 2 - Part 1 2022-12-03 15:43:52 +01:00
91339c9d02 Add 2022 - Day 1 - Part 2 2022-12-03 13:32:12 +01:00
fb795c2a38 Add 2022 - Day 1 - Part 1 2022-12-03 13:28:29 +01:00
0fd3573077 Add folder for Python scripts for 2022 & update README 2022-12-03 13:28:29 +01:00
c199556965 Improve README 2022-12-03 13:28:29 +01:00
f4b90f89e8 Move and rename input files 2022-12-03 04:51:10 +01:00
64 changed files with 8505 additions and 44 deletions

View File

@@ -16,7 +16,7 @@ extern void print(const char *format, ...) {
}
int main(void) {
char *input = readFile("input/1.txt");
char *input = readFile("input.txt");
if (input == NULL) {
return 1;

2
2017/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/.idea/*
!/.idea/runConfigurations

1
2017/01/input.txt Normal file
View File

@@ -0,0 +1 @@
494751136895345894732582362629576539599184296195318162664695189393364372585778868512194863927652788149779748657989318645936221887731542718562643272683862627537378624843614831337441659741281289638765171452576466381314558821636595394981788588673443769343597851883955668818165723174939893841654914556681324133667446412138511724424292394454166623639872425168644336248217213826339741267546823779383343362789527461579565822966859349777937921933694912369552152772735167832762563719664315456987186713541153781499646178238762644186484381142249926194743713139262596264878458636595896487362658672224346241358667234115974528626523648311919886566497837217169673923935143386823757293148719377821517314629812886912412829924484513493885672343964151252433622341141661523814465991516961684511941471572895453711624986269342398786175846925783918686856442684489873327497698963658862856336682422797551251489126661954848572297228765445646745256499679451426358865477844467458533962981852292513358871483321161973583245698763531598395467675529181496911117769834127516441369261275244225978893617456524385518493112272169767775861256649728253754964675812534546226295535939697352141217337346738553495616832783757866928174519145357234834584788253893618549484385733283627199445369658339175644484859385884574943219267922729967571943843794565736975716174727852348441254492886794362934343868643337828637454277582276962353246357835493338372219824371517526474283541714897994127864461433627894831268659336264234436872715374727211764167739169341999573855627775114848275268739159272518673316753672995297888734844388928439859359992475637439771269232916542385876779616695129412366735112593669719335783511355773814685491876721452994714318863716542473187246351548626157775143333161422867924437526253865859969947366972895674966845993244925218766937543487875485647329995285821739359369998935331986126873726737672159265827566443794515755939813676194755474477224152139987944419463371386499841415227734673733555261543871359797796529847861748979527579985757964742667473767269248335229836818297477665453189662485548925521497365877771665365728224394427883312135322325169141784

28
2017/01/main.sql Normal file
View File

@@ -0,0 +1,28 @@
CALL aoc_load_file_lines('01');
CREATE TABLE "01.characters" AS
SELECT r.row - 1 AS index, r.character
FROM "01.input"
CROSS JOIN REGEXP_SPLIT_TO_TABLE(input, '') WITH ORDINALITY AS r(character, row);
CREATE UNIQUE INDEX "01.characters.index" ON "01.characters" (index);
UPDATE "01.output"
SET result = (
SELECT SUM(a.character::INT) AS result
FROM "01.characters" a
INNER JOIN "01.characters" b ON a.index = (b.index + 1) % (SELECT MAX(index) + 1 FROM "01.characters")
WHERE a.character = b.character
)
WHERE part = 1;
UPDATE "01.output"
SET result = (
SELECT SUM(a.character::INT) AS result
FROM "01.characters" a
INNER JOIN "01.characters" b ON a.index = (b.index + (SELECT (MAX(index) + 1) / 2 FROM "01.characters")) % (SELECT MAX(index) + 1 FROM "01.characters")
WHERE a.character = b.character
)
WHERE part = 2;
SELECT aoc_results('01')

16
2017/02/input.txt Normal file
View File

@@ -0,0 +1,16 @@
414 382 1515 319 83 1327 116 391 101 749 1388 1046 1427 105 1341 1590
960 930 192 147 932 621 1139 198 865 820 597 165 232 417 19 183
3379 987 190 3844 1245 1503 3151 3349 2844 4033 175 3625 3565 179 3938 184
116 51 32 155 102 92 65 42 48 91 74 69 52 89 20 143
221 781 819 121 821 839 95 117 626 127 559 803 779 543 44 369
199 2556 93 1101 122 124 2714 625 2432 1839 2700 2636 118 2306 1616 2799
56 804 52 881 1409 47 246 1368 1371 583 49 1352 976 400 1276 1240
1189 73 148 1089 93 76 3205 3440 3627 92 853 95 3314 3551 2929 3626
702 169 492 167 712 488 357 414 187 278 87 150 19 818 178 686
140 2220 1961 1014 2204 2173 1513 2225 443 123 148 580 833 1473 137 245
662 213 1234 199 1353 1358 1408 235 917 1395 1347 194 565 179 768 650
119 137 1908 1324 1085 661 1557 1661 1828 1865 432 110 658 821 1740 145
1594 222 4140 963 209 2782 180 2591 4390 244 4328 3748 4535 192 157 3817
334 275 395 128 347 118 353 281 430 156 312 386 160 194 63 141
146 1116 153 815 2212 2070 599 3018 2640 47 125 2292 165 2348 2694 184
1704 2194 1753 146 2063 1668 1280 615 163 190 2269 1856 150 158 2250 2459

19
2017/02/main.sql Normal file
View File

@@ -0,0 +1,19 @@
CALL aoc_load_file_lines('02');
CALL aoc_input_extract_cells('02', '\t', 'INT');
UPDATE "02.output" SET result = (
SELECT SUM(row.difference)
FROM (
SELECT MAX(value::INT) - MIN(value::INT) AS difference
FROM "02.input.cells"
GROUP BY row
) row
) WHERE part = 1;
UPDATE "02.output" SET result = (
SELECT SUM(a.value / b.value)
FROM "02.input.cells" a
INNER JOIN "02.input.cells" b ON a.row = b.row AND a.value != b.value AND a.value % b.value = 0
) WHERE part = 2;
SELECT aoc_results('02');

19
2017/docker-compose.yml Normal file
View File

@@ -0,0 +1,19 @@
version: "3.9"
services:
postgres:
image: postgres:15
container_name: "aoc-2017-postgres"
ports:
- "127.0.0.1:2017:5432"
volumes:
- postgres:/var/lib/postgresql/data
- .:/aoc:ro
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: aoc2017
POSTGRES_DB: postgres
volumes:
postgres:
name: "aoc-2017-postgres"

55
2017/utils/procedures.sql Normal file
View File

@@ -0,0 +1,55 @@
CREATE OR REPLACE PROCEDURE aoc_drop_tables(day TEXT) AS
$$
DECLARE
row RECORD;
BEGIN
FOR row IN
SELECT table_name
FROM information_schema.tables
WHERE table_name LIKE (day || '.%') AND table_schema = CURRENT_SCHEMA()
LOOP
EXECUTE FORMAT('DROP TABLE %I CASCADE', row.table_name);
END LOOP;
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE PROCEDURE aoc_setup_tables(day TEXT, input_columns TEXT) AS
$$
BEGIN
CALL aoc_drop_tables(day);
EXECUTE FORMAT('CREATE TABLE %I (%s)', day || '.input', input_columns);
EXECUTE FORMAT('CREATE TABLE %I (part INT, result TEXT NULL)', day || '.output');
EXECUTE FORMAT('INSERT INTO %I (part) VALUES (1), (2)', day || '.output');
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION aoc_results(day TEXT)
RETURNS TABLE (
RESULT TEXT
)
STABLE
ROWS 2
AS
$$
BEGIN
RETURN QUERY EXECUTE FORMAT('SELECT result FROM %I ORDER BY part', day || '.output');
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE PROCEDURE aoc_load_file_lines(day TEXT) AS
$$
BEGIN
CALL aoc_setup_tables(day, 'input TEXT');
EXECUTE FORMAT('COPY %I FROM ''/aoc/%s/input.txt'' WITH DELIMITER E''\1''', day || '.input', day);
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE PROCEDURE aoc_input_extract_cells(day TEXT, delimiter TEXT, value_type TEXT) AS
$$
BEGIN
EXECUTE FORMAT('CREATE TABLE %I AS
SELECT input.row, cell.col, cell.value::%s
FROM (SELECT ROW_NUMBER() OVER () AS row, input AS line FROM %I) input
CROSS JOIN REGEXP_SPLIT_TO_TABLE(input.line, %L) WITH ORDINALITY AS cell(value, col)', day || '.input.cells', value_type, day || '.input', delimiter);
END
$$ LANGUAGE plpgsql;

View File

@@ -8,7 +8,7 @@ use std::io::{BufRead, BufReader};
use std::str::FromStr;
pub fn read_input_lines() -> Result<Vec<String>, io::Error> {
let file = File::open("input/1.txt")?;
let file = File::open("input.txt")?;
return BufReader::new(file).lines().collect();
}

View File

@@ -1,7 +1,7 @@
import java.io.File
fun main() {
val lines = File("input/1.txt").readLines().map(String::toInt)
val lines = File("input.txt").readLines().map(String::toInt)
val totalIncreases = lines.windowed(2).count { it[1] > it[0] }
val windowedIncreases = lines.windowed(3).map(List<Int>::sum).windowed(2).count { it[1] > it[0] }

View File

@@ -1,7 +1,7 @@
import java.io.File
fun main() {
val lines = File("input/1.txt").readLines()
val lines = File("input.txt").readLines()
val directions = lines.map { line -> line.split(' ', limit = 2).let { it[0] to it[1].toInt() } }
println("Part 1:")

View File

@@ -1,7 +1,7 @@
import java.io.File
fun main() {
val lines = File("input/1.txt").readLines().filter(String::isNotEmpty)
val lines = File("input.txt").readLines().filter(String::isNotEmpty)
val input = Input(lines)
part1(input)
part2(input)

View File

@@ -3,7 +3,7 @@ import java.io.File
const val SIZE = 5
fun main() {
val lineIterator = File("input/1.txt").readLines().iterator()
val lineIterator = File("input.txt").readLines().iterator()
val numbersToDraw = lineIterator.next().split(',').map(String::toInt).toList()
val boards = mutableListOf<Board>()

View File

@@ -6,7 +6,7 @@ import kotlin.system.measureTimeMillis
fun main() {
val lineRegex = Regex("^(\\d+),(\\d+) -> (\\d+),(\\d+)$")
val lines = File("input/1.txt").readLines()
val lines = File("input.txt").readLines()
.mapNotNull(lineRegex::matchEntire)
.map { it.groupValues.takeLast(4).map(String::toInt) }
.map { Line(it[0], it[1], it[2], it[3]) }
@@ -15,7 +15,7 @@ fun main() {
println("(Took ${measureTimeMillis { part2(lines) }} ms)")
}
@Suppress("ProtectedInFinal", "MemberVisibilityCanBePrivate")
@Suppress("MemberVisibilityCanBePrivate")
data class Line(val x1: Int, val y1: Int, val x2: Int, val y2: Int) {
val minX = min(x1, x2)
val minY = min(y1, y2)

View File

@@ -3,7 +3,7 @@ import java.math.BigInteger
import kotlin.system.measureTimeMillis
fun main() {
val initialConfiguration = File("input/1.txt").readLines()
val initialConfiguration = File("input.txt").readLines()
.single()
.split(',')
.map(String::toInt)

View File

@@ -2,7 +2,7 @@ import java.io.File
import kotlin.math.abs
fun main() {
val originalPositions = File("input/1.txt").readLines().single().split(',').map(String::toInt).toIntArray()
val originalPositions = File("input.txt").readLines().single().split(',').map(String::toInt).toIntArray()
val p1 = originalPositions.minOrNull() ?: return
val p2 = originalPositions.maxOrNull() ?: return

View File

@@ -9,7 +9,7 @@ import java.io.File
import java.util.EnumSet
fun main() {
val records = File("input/1.txt").readLines().map { line ->
val records = File("input.txt").readLines().map { line ->
line.split(" | ", limit = 2).map { it.split(' ') }.let { Record(it[0], it[1]) }
}
@@ -19,7 +19,7 @@ fun main() {
fun part1(records: List<Record>) {
@Suppress("ConvertLambdaToReference")
val segmentCountToDigits = DIGITS
val segmentCountToDigits = allDigits
.map { it.value to it.positions.size }
.groupBy { it.second }
.mapValues { it.value.map { e -> e.first } }
@@ -48,7 +48,7 @@ enum class Position {
BOTTOM
}
private val DIGITS = listOf(
private val allDigits = listOf(
Digit(0, EnumSet.of(TOP, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, BOTTOM)),
Digit(1, EnumSet.of(TOP_RIGHT, BOTTOM_RIGHT)),
Digit(2, EnumSet.of(TOP, TOP_RIGHT, MIDDLE, BOTTOM_LEFT, BOTTOM)),
@@ -124,7 +124,7 @@ data class Record(val patterns: List<String>, val output: List<String>) {
return output.fold(0) { total, digit ->
val positions = digit.map(mapping::getValue).toSet()
val value = DIGITS.first { it.positions == positions }.value
val value = allDigits.first { it.positions == positions }.value
(total * 10) + value
}

View File

@@ -17,30 +17,24 @@ dependencies {
}
idea {
module.excludeDirs.addAll(listOf(
file(".gradle"),
file("build"),
file("gradle"),
))
module.excludeDirs.add(file("gradle"))
}
sourceSets {
fun make(day: Int) {
val paddedDay = day.toString().padStart(2, '0')
val sourceFolder = file(paddedDay)
val resourceFolder = sourceFolder.resolve("input")
if (!sourceFolder.exists()) {
sourceFolder.mkdir()
sourceFolder.resolve("main.kt").writeText("fun main() {\n\t\n}")
resourceFolder.mkdir()
resourceFolder.resolve("1.txt").writeText("")
sourceFolder.resolve("input.txt").writeText("")
}
create(paddedDay) {
java.setSrcDirs(listOf(sourceFolder))
resources.setSrcDirs(listOf(resourceFolder))
resources.setSrcDirs(listOf(sourceFolder))
resources.include("*.txt")
}
tasks.register<JavaExec>(paddedDay) {

2
2022/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/.idea/*
!/.idea/runConfigurations

24
2022/.idea/runConfigurations/Day_01.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 01" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/01" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/01/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

24
2022/.idea/runConfigurations/Day_02.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 02" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/02" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/02/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

24
2022/.idea/runConfigurations/Day_03.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 03" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/03" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/03/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

24
2022/.idea/runConfigurations/Day_04.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 04" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/04" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/04/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

24
2022/.idea/runConfigurations/Day_05.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 05" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/05" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/05/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

24
2022/.idea/runConfigurations/Day_06.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 06" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/06" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/06/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

24
2022/.idea/runConfigurations/Day_07.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 07" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/07" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/07/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

24
2022/.idea/runConfigurations/Day_08.xml generated Normal file
View File

@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Day 08" type="PythonConfigurationType" factoryName="Python">
<module name="2022" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/08" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/08/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

2262
2022/01/input.txt Normal file

File diff suppressed because it is too large Load Diff

17
2022/01/main.py Normal file
View File

@@ -0,0 +1,17 @@
from itertools import groupby
from utils.input import read_input_lines
lines = read_input_lines()
groups = [list(group) for is_group, group in groupby(lines, lambda x: x != '') if is_group]
carrying_calories = ((int(item) for item in group) for group in groups)
carrying_total_calories = [sum(group) for group in carrying_calories]
most_calories_carried = max(carrying_total_calories)
print(f"Most calories carried: {most_calories_carried}")
top3_most_calories_carried = sorted(carrying_total_calories, reverse=True)[:3]
top3_most_calories_carried_total = sum(top3_most_calories_carried)
print(f"Total calories carried by the top 3: {top3_most_calories_carried_total}")

2500
2022/02/input.txt Normal file

File diff suppressed because it is too large Load Diff

88
2022/02/main.py Normal file
View File

@@ -0,0 +1,88 @@
from enum import Enum
from typing import Callable
from utils.input import read_input_lines
class Move(Enum):
ROCK = 1
PAPER = 2
SCISSORS = 3
def __init__(self, points: int):
self.points = points
class Outcome(Enum):
LOSS = 0
DRAW = 3
WIN = 6
def __init__(self, points: int):
self.points = points
def play_game_from_line(line: str, strategy: Callable[[Move, str], Move]) -> int:
(opponent_char, response_char) = line.split(" ", maxsplit = 2)
match opponent_char:
case "A": opponent = Move.ROCK
case "B": opponent = Move.PAPER
case "C": opponent = Move.SCISSORS
case _: raise ValueError(f"Invalid opponent move: {opponent_char}")
response = strategy(opponent, response_char)
outcome = play_game(response, opponent)
return response.points + outcome.points
def play_game(me: Move, opponent: Move) -> Outcome:
if me == opponent:
return Outcome.DRAW
elif me == Move.ROCK:
return Outcome.WIN if opponent == Move.SCISSORS else Outcome.LOSS
elif me == Move.PAPER:
return Outcome.WIN if opponent == Move.ROCK else Outcome.LOSS
elif me == Move.SCISSORS:
return Outcome.WIN if opponent == Move.PAPER else Outcome.LOSS
else:
raise ValueError(f"Invalid move: {me}")
# noinspection PyShadowingNames
def play_games_from_all_lines(lines: list[str], strategy) -> int:
return sum(play_game_from_line(line, strategy) for line in lines)
def strategy_response_char_determines_move(_: Move, response_char: str) -> Move:
match response_char:
case "X": return Move.ROCK
case "Y": return Move.PAPER
case "Z": return Move.SCISSORS
case _: raise ValueError(f"Invalid response move: {response_char}")
def strategy_response_char_determines_outcome(opponent: Move, response_char: str) -> Move:
match response_char:
case "Y": # Draw
return opponent
case "Z": # Win
match opponent:
case Move.ROCK: return Move.PAPER
case Move.PAPER: return Move.SCISSORS
case Move.SCISSORS: return Move.ROCK
case "X": # Lose
match opponent:
case Move.ROCK: return Move.SCISSORS
case Move.PAPER: return Move.ROCK
case Move.SCISSORS: return Move.PAPER
case _:
raise ValueError(f"Invalid response move: {response_char}")
lines = read_input_lines()
first_strategy_score = play_games_from_all_lines(lines, strategy_response_char_determines_move)
second_strategy_score = play_games_from_all_lines(lines, strategy_response_char_determines_outcome)
print(f"First strategy score: {first_strategy_score}")
print(f"Second strategy score: {second_strategy_score}")

300
2022/03/input.txt Normal file
View File

@@ -0,0 +1,300 @@
VdzVHmNpdVmBBCpmQLTNfTtMhMJnhFhTTf
FgqsZbqDDFqRrhhJnsnLMTfhJG
bRRRPrRRwSwbDqgjvDZbRbQzpzmQVWCzzBdvQBFCzlWV
GcDdRdvhRssRhGDdShCRtqWjlQzqWgqzNfNjfQWWjt
mwwnnPFwmVrPmJmzfNzqCjQCbgVlgC
nPnHHLrHwmJTrCTJpThBscBSdSLGZvZBvRhZ
RVQQcVlcSRclfZCCCnMJJTSTnC
NdHwjdwjbBBZrrZrbJDZJJ
wmhjGGBGwwmjtjtdPlfRcpVQlhRppVJF
pplbNBPPrppllrFNbpvppSTcwqcWFhTTShhJDTchqd
RGzRfLjjmZmfmwLftTWhStStJWTdWmDm
nfsMjQssnpPvNnrPrw
SjjBgllzlQjBZvlBBgcFbgJHsMhJqbMHPggJbM
hRLRVDdRRWnJqnnHTqMCnH
GRfLddRRpVhNVrWSjwQQzSzcGSBQSc
qMwNqqBdQdnTVBBVVhMVnVFzTHPggTPjG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nLgDnTggdtd
PPfMcZMflbMQcMllPVfTVMwjWWmZvpWWpWhhjjpdWWww
sDQNnzsnQgDNsFzFqtGjGmWWSpWrGhdpvphdSW
nNQNqLBHLqzDnHgnVJfPJPCRBbfCcJlT
fppppWsjcSDPjjDpGhgwbfTgHTCbHJwbHbTR
rLBdQnvMNMmFPbLqHqTqgLHCgL
nrFznvMNMQdttrBcScsDstWcPGtWSc
lclnRSDnGZtvSwnZDZzhLffqdsCNwTBCBBdNsd
mPjmjmrFFpmQjMJQjlNdlhCsCLsTlNLs
ggmrHHVVQVPJpWrgpWScRvzZzGGRnZvlgzZn
GjGJGQJGcMTVfFDQzNVQzP
mHqdbmmdnJqVzVhRVNzPbR
wStmHJsJsLZLjTvM
QssMbVGdMQjZPjwVwHVZPZClllvgSgvlTgwwSSCgSCtC
WmmFBmJrcFRBFrJJBFchzWCStgCTgvhvTlfsNqfTlvTv
sFzzssDLzrBPjDVVddHMQD
fztDZSGrNrlnbnPTgFFpln
jvvQMMcLcjJmQwHdJvjQJnnbTbRFRphnnpsWgmFRPR
vTLHHCQLHBBjJCSZrVCZtSfSfrft
gHfHffHLjwHrRjLrLRZVMnTdTBsNTBwTVBsBnN
DWPhqhhDhvSGvWPzSzMBQBQVMMBBmvssvQvQ
CDGbqCDbChSbWGrHcHRgbcVcfrLJ
frlTLmtllbbbdpJS
qFjhzjThjHTFGHTjqhhjMzBhVpVpdbBnSJQRpBnVVdbRRQJd
vjWPWjWPPPWgwmfCrNvTvZ

34
2022/03/main.py Normal file
View File

@@ -0,0 +1,34 @@
from itertools import chain, zip_longest
from utils.input import read_input_lines
def middle(iterable) -> int:
return int(len(iterable) / 2)
lines = read_input_lines()
compartments = ((set(line[middle(line):]), set(line[:middle(line)])) for line in lines)
misplaced_item_sets = (set.intersection(*compartment) for compartment in compartments)
misplaced_items = chain.from_iterable(misplaced_item_sets)
def get_priority(item: chr) -> int:
if 'a' <= item <= 'z':
return ord(item) - ord('a') + 1
elif 'A' <= item <= 'Z':
return ord(item) - ord('A') + 27
else:
raise ValueError(f"Invalid item: {item}")
total_misplaced_priority = sum(map(get_priority, misplaced_items))
print(f"Total misplaced item priority: {total_misplaced_priority}")
line_iterator = iter(lines)
rucksacks_per_group = zip_longest(line_iterator, line_iterator, line_iterator)
rucksack_items_per_group = (list(set(item) for item in rucksack) for rucksack in rucksacks_per_group)
common_items_per_group = (set.intersection(*rucksack_items) for rucksack_items in rucksack_items_per_group)
badges = chain.from_iterable(common_items_per_group)
total_badge_priority = sum(map(get_priority, badges))
print(f"Total badge priority: {total_badge_priority}")

1000
2022/04/input.txt Normal file

File diff suppressed because it is too large Load Diff

51
2022/04/main.py Normal file
View File

@@ -0,0 +1,51 @@
from utils.input import read_input_lines
class Assignment:
def __init__(self, first_section: int, last_section: int):
self.first_section = first_section
self.last_section = last_section
def __repr__(self) -> str:
return f"{self.first_section}-{self.last_section}"
def contains(self, other: "Assignment") -> bool:
return self.first_section <= other.first_section and self.last_section >= other.last_section
def overlaps(self, other: "Assignment") -> bool:
return self.first_section in range(other.first_section, other.last_section + 1) or self.last_section in range(other.first_section, other.last_section + 1)
@staticmethod
def from_str(line: str) -> "Assignment":
(first_section, last_section) = line.split("-", maxsplit = 1)
return Assignment(int(first_section), int(last_section))
class Pair:
def __init__(self, first: Assignment, second: Assignment):
self.first = first
self.second = second
def __repr__(self) -> str:
return f"{self.first}, {self.second}"
def has_full_overlap(self) -> bool:
return self.first.contains(self.second) or self.second.contains(self.first)
def has_any_overlap(self) -> bool:
return self.first.overlaps(self.second) or self.second.overlaps(self.first)
@staticmethod
def from_line(line: str) -> "Pair":
(first, second) = line.split(",", maxsplit = 1)
return Pair(Assignment.from_str(first), Assignment.from_str(second))
lines = read_input_lines()
pairs = list(map(lambda line: Pair.from_line(line), lines))
assignments_with_full_overlap = sum(1 for pair in pairs if pair.has_full_overlap())
print(f"Amount of assignments with full overlap: {assignments_with_full_overlap}")
assignments_with_any_overlap = sum(1 for pair in pairs if pair.has_any_overlap())
print(f"Amount of assignments with any overlap: {assignments_with_any_overlap}")

512
2022/05/input.txt Normal file
View File

@@ -0,0 +1,512 @@
[H] [D] [P]
[W] [B] [C] [Z] [D]
[T] [J] [T] [J] [D] [J]
[H] [Z] [H] [H] [W] [S] [M]
[P] [F] [R] [P] [Z] [F] [W] [F]
[J] [V] [T] [N] [F] [G] [Z] [S] [S]
[C] [R] [P] [S] [V] [M] [V] [D] [Z]
[F] [G] [H] [Z] [N] [P] [M] [N] [D]
1 2 3 4 5 6 7 8 9
move 2 from 8 to 2
move 3 from 9 to 2
move 1 from 3 to 8
move 5 from 1 to 7
move 2 from 9 to 2
move 8 from 2 to 4
move 6 from 7 to 2
move 2 from 1 to 7
move 4 from 5 to 9
move 4 from 5 to 6
move 1 from 8 to 3
move 1 from 8 to 5
move 2 from 9 to 8
move 8 from 6 to 4
move 4 from 3 to 6
move 10 from 2 to 3
move 1 from 5 to 1
move 1 from 7 to 4
move 2 from 9 to 8
move 18 from 4 to 8
move 1 from 1 to 6
move 4 from 7 to 3
move 12 from 8 to 4
move 4 from 7 to 9
move 5 from 6 to 9
move 2 from 2 to 7
move 3 from 9 to 5
move 3 from 5 to 9
move 1 from 2 to 8
move 10 from 3 to 1
move 2 from 7 to 8
move 10 from 1 to 9
move 1 from 3 to 5
move 16 from 9 to 8
move 1 from 3 to 2
move 3 from 8 to 3
move 1 from 5 to 9
move 3 from 6 to 7
move 2 from 7 to 2
move 1 from 3 to 8
move 5 from 4 to 1
move 4 from 9 to 5
move 2 from 2 to 5
move 2 from 1 to 9
move 23 from 8 to 4
move 6 from 5 to 2
move 5 from 2 to 6
move 1 from 9 to 6
move 2 from 2 to 4
move 35 from 4 to 9
move 1 from 6 to 1
move 2 from 8 to 7
move 1 from 6 to 8
move 3 from 1 to 7
move 1 from 7 to 1
move 3 from 6 to 2
move 4 from 3 to 7
move 6 from 7 to 9
move 1 from 6 to 9
move 1 from 8 to 1
move 2 from 2 to 9
move 2 from 8 to 2
move 3 from 7 to 3
move 2 from 1 to 9
move 5 from 9 to 3
move 1 from 4 to 2
move 1 from 1 to 4
move 7 from 3 to 9
move 1 from 3 to 4
move 2 from 4 to 7
move 24 from 9 to 4
move 12 from 9 to 3
move 1 from 3 to 1
move 1 from 1 to 2
move 2 from 2 to 6
move 1 from 6 to 5
move 1 from 6 to 8
move 3 from 2 to 4
move 1 from 7 to 4
move 1 from 5 to 3
move 1 from 9 to 8
move 23 from 4 to 8
move 17 from 8 to 5
move 12 from 9 to 8
move 10 from 8 to 7
move 1 from 8 to 6
move 5 from 4 to 3
move 3 from 5 to 1
move 3 from 1 to 6
move 6 from 5 to 4
move 10 from 3 to 1
move 9 from 1 to 7
move 2 from 4 to 9
move 1 from 1 to 6
move 4 from 8 to 1
move 4 from 3 to 7
move 4 from 6 to 5
move 1 from 9 to 6
move 1 from 9 to 2
move 1 from 1 to 7
move 1 from 2 to 7
move 3 from 1 to 7
move 9 from 5 to 9
move 7 from 9 to 7
move 2 from 9 to 1
move 3 from 5 to 9
move 3 from 4 to 8
move 1 from 1 to 2
move 1 from 2 to 6
move 1 from 1 to 6
move 5 from 8 to 7
move 1 from 8 to 1
move 1 from 3 to 9
move 1 from 1 to 6
move 2 from 9 to 5
move 2 from 3 to 9
move 4 from 6 to 3
move 1 from 9 to 4
move 2 from 4 to 8
move 1 from 4 to 8
move 1 from 9 to 5
move 1 from 6 to 8
move 23 from 7 to 8
move 27 from 8 to 2
move 2 from 8 to 1
move 23 from 2 to 6
move 3 from 5 to 3
move 4 from 2 to 5
move 2 from 3 to 1
move 2 from 9 to 3
move 4 from 1 to 4
move 13 from 7 to 9
move 1 from 5 to 6
move 2 from 5 to 9
move 1 from 5 to 3
move 3 from 9 to 3
move 5 from 9 to 5
move 2 from 4 to 2
move 1 from 4 to 9
move 11 from 6 to 9
move 9 from 6 to 1
move 17 from 9 to 5
move 3 from 7 to 4
move 3 from 6 to 3
move 14 from 5 to 2
move 5 from 3 to 1
move 2 from 9 to 4
move 2 from 3 to 8
move 5 from 5 to 9
move 2 from 5 to 4
move 7 from 1 to 8
move 2 from 9 to 5
move 3 from 9 to 8
move 8 from 4 to 2
move 2 from 7 to 8
move 10 from 2 to 9
move 10 from 2 to 6
move 8 from 9 to 7
move 2 from 3 to 9
move 3 from 9 to 8
move 5 from 3 to 9
move 7 from 7 to 9
move 3 from 2 to 9
move 10 from 8 to 5
move 1 from 7 to 6
move 1 from 2 to 3
move 4 from 1 to 6
move 2 from 8 to 4
move 1 from 4 to 6
move 2 from 6 to 3
move 2 from 3 to 1
move 1 from 4 to 9
move 4 from 1 to 5
move 2 from 5 to 2
move 2 from 8 to 4
move 1 from 3 to 5
move 3 from 5 to 7
move 2 from 2 to 9
move 3 from 7 to 6
move 3 from 8 to 5
move 10 from 5 to 7
move 3 from 6 to 4
move 11 from 6 to 1
move 3 from 6 to 2
move 12 from 1 to 3
move 1 from 7 to 5
move 9 from 7 to 3
move 5 from 5 to 1
move 4 from 4 to 6
move 2 from 1 to 7
move 1 from 2 to 6
move 2 from 7 to 8
move 1 from 2 to 4
move 1 from 9 to 5
move 3 from 6 to 7
move 1 from 5 to 2
move 9 from 9 to 5
move 1 from 2 to 8
move 1 from 4 to 8
move 1 from 1 to 8
move 1 from 4 to 2
move 1 from 7 to 2
move 1 from 6 to 2
move 1 from 6 to 8
move 6 from 9 to 6
move 1 from 3 to 4
move 9 from 3 to 5
move 1 from 1 to 3
move 2 from 2 to 6
move 1 from 3 to 5
move 14 from 5 to 1
move 1 from 2 to 6
move 5 from 6 to 4
move 3 from 8 to 2
move 5 from 6 to 1
move 5 from 4 to 6
move 1 from 7 to 1
move 3 from 9 to 3
move 7 from 5 to 7
move 1 from 4 to 6
move 2 from 7 to 5
move 3 from 6 to 1
move 3 from 8 to 1
move 14 from 3 to 4
move 8 from 4 to 2
move 1 from 6 to 1
move 15 from 1 to 6
move 7 from 1 to 6
move 6 from 1 to 3
move 3 from 3 to 1
move 2 from 4 to 5
move 1 from 4 to 2
move 19 from 6 to 8
move 2 from 1 to 8
move 4 from 5 to 4
move 7 from 8 to 2
move 2 from 3 to 1
move 13 from 8 to 6
move 4 from 4 to 9
move 2 from 4 to 8
move 2 from 1 to 6
move 1 from 3 to 5
move 19 from 2 to 3
move 13 from 3 to 1
move 1 from 4 to 9
move 1 from 2 to 8
move 3 from 7 to 1
move 14 from 6 to 9
move 2 from 6 to 4
move 18 from 9 to 4
move 3 from 7 to 2
move 15 from 1 to 4
move 2 from 1 to 8
move 5 from 3 to 1
move 1 from 3 to 6
move 5 from 8 to 9
move 3 from 9 to 5
move 1 from 9 to 5
move 1 from 8 to 9
move 1 from 6 to 2
move 3 from 9 to 4
move 2 from 6 to 7
move 30 from 4 to 6
move 22 from 6 to 9
move 6 from 9 to 4
move 4 from 6 to 7
move 1 from 1 to 6
move 1 from 9 to 8
move 1 from 7 to 6
move 3 from 5 to 3
move 5 from 6 to 5
move 2 from 7 to 9
move 4 from 1 to 5
move 1 from 6 to 4
move 1 from 8 to 7
move 2 from 6 to 4
move 17 from 9 to 8
move 2 from 2 to 7
move 2 from 3 to 1
move 8 from 4 to 8
move 1 from 3 to 8
move 8 from 4 to 2
move 2 from 1 to 2
move 1 from 4 to 6
move 4 from 7 to 1
move 1 from 6 to 8
move 19 from 8 to 3
move 5 from 5 to 1
move 5 from 5 to 9
move 2 from 9 to 3
move 6 from 1 to 9
move 1 from 7 to 5
move 1 from 7 to 4
move 2 from 5 to 7
move 2 from 2 to 4
move 4 from 9 to 8
move 12 from 8 to 7
move 2 from 1 to 9
move 1 from 7 to 4
move 4 from 4 to 5
move 3 from 9 to 3
move 9 from 2 to 6
move 2 from 7 to 5
move 1 from 1 to 9
move 5 from 9 to 7
move 9 from 6 to 2
move 6 from 2 to 8
move 21 from 3 to 2
move 12 from 2 to 9
move 3 from 5 to 9
move 3 from 3 to 8
move 5 from 9 to 6
move 13 from 2 to 3
move 3 from 6 to 2
move 10 from 9 to 8
move 6 from 3 to 1
move 3 from 2 to 9
move 2 from 6 to 7
move 5 from 3 to 9
move 4 from 1 to 9
move 3 from 8 to 5
move 1 from 1 to 7
move 6 from 5 to 7
move 12 from 9 to 7
move 1 from 1 to 8
move 11 from 8 to 5
move 9 from 5 to 7
move 1 from 3 to 1
move 4 from 8 to 7
move 1 from 1 to 7
move 2 from 8 to 3
move 42 from 7 to 4
move 3 from 7 to 9
move 4 from 7 to 5
move 1 from 7 to 8
move 1 from 8 to 5
move 1 from 7 to 5
move 1 from 3 to 4
move 1 from 3 to 9
move 1 from 9 to 6
move 1 from 6 to 4
move 1 from 3 to 5
move 3 from 9 to 2
move 16 from 4 to 8
move 3 from 2 to 4
move 1 from 5 to 4
move 30 from 4 to 6
move 15 from 8 to 3
move 2 from 4 to 5
move 1 from 8 to 7
move 13 from 3 to 6
move 1 from 7 to 8
move 1 from 3 to 8
move 1 from 3 to 8
move 4 from 5 to 2
move 6 from 5 to 2
move 2 from 8 to 6
move 43 from 6 to 2
move 1 from 6 to 1
move 18 from 2 to 4
move 24 from 2 to 6
move 19 from 6 to 3
move 4 from 6 to 3
move 2 from 6 to 3
move 3 from 3 to 2
move 1 from 1 to 3
move 23 from 3 to 6
move 12 from 4 to 3
move 7 from 3 to 9
move 13 from 2 to 9
move 1 from 8 to 4
move 4 from 3 to 8
move 6 from 4 to 2
move 10 from 9 to 3
move 6 from 2 to 9
move 8 from 3 to 5
move 3 from 5 to 3
move 13 from 6 to 5
move 4 from 3 to 9
move 1 from 4 to 2
move 4 from 8 to 3
move 1 from 2 to 5
move 14 from 9 to 5
move 2 from 5 to 4
move 2 from 4 to 3
move 1 from 9 to 5
move 4 from 6 to 1
move 1 from 6 to 2
move 6 from 3 to 2
move 5 from 6 to 8
move 2 from 3 to 7
move 1 from 8 to 1
move 25 from 5 to 7
move 3 from 7 to 9
move 5 from 2 to 9
move 12 from 9 to 8
move 3 from 1 to 6
move 16 from 8 to 2
move 1 from 9 to 2
move 1 from 6 to 2
move 1 from 1 to 3
move 21 from 7 to 3
move 2 from 7 to 1
move 1 from 7 to 8
move 2 from 2 to 1
move 2 from 6 to 3
move 18 from 2 to 9
move 2 from 5 to 1
move 1 from 2 to 1
move 3 from 5 to 2
move 13 from 9 to 1
move 3 from 9 to 2
move 1 from 8 to 7
move 3 from 2 to 6
move 2 from 5 to 1
move 17 from 3 to 8
move 3 from 3 to 8
move 2 from 9 to 1
move 1 from 7 to 5
move 1 from 5 to 3
move 2 from 6 to 4
move 1 from 6 to 1
move 15 from 8 to 2
move 2 from 3 to 6
move 1 from 8 to 5
move 2 from 6 to 8
move 13 from 2 to 9
move 4 from 9 to 8
move 9 from 8 to 9
move 3 from 3 to 4
move 4 from 9 to 7
move 1 from 8 to 6
move 1 from 7 to 5
move 2 from 5 to 1
move 1 from 6 to 3
move 4 from 4 to 5
move 1 from 4 to 6
move 1 from 3 to 7
move 1 from 5 to 6
move 2 from 7 to 2
move 4 from 2 to 3
move 3 from 2 to 7
move 1 from 3 to 6
move 1 from 9 to 6
move 2 from 5 to 2
move 3 from 9 to 5
move 1 from 6 to 1
move 3 from 5 to 4
move 12 from 1 to 2
move 2 from 2 to 4
move 2 from 7 to 8
move 2 from 3 to 9
move 1 from 4 to 7
move 1 from 5 to 2
move 1 from 8 to 3
move 2 from 3 to 6
move 7 from 2 to 8
move 3 from 4 to 1
move 7 from 8 to 5
move 7 from 9 to 2
move 1 from 4 to 5
move 3 from 7 to 6
move 5 from 6 to 9
move 6 from 9 to 5
move 4 from 9 to 6
move 1 from 8 to 5
move 1 from 7 to 4
move 1 from 4 to 2
move 2 from 2 to 9
move 2 from 9 to 2
move 11 from 5 to 3
move 2 from 5 to 2
move 1 from 2 to 9
move 4 from 6 to 9
move 1 from 2 to 9
move 4 from 3 to 7
move 3 from 6 to 4
move 1 from 5 to 7
move 18 from 1 to 3
move 11 from 3 to 2
move 1 from 7 to 9
move 1 from 5 to 9
move 14 from 3 to 6
move 15 from 2 to 4
move 5 from 2 to 5
move 1 from 2 to 5
move 1 from 1 to 9
move 8 from 4 to 1
move 5 from 5 to 9
move 9 from 4 to 9
move 4 from 7 to 4
move 5 from 4 to 8
move 2 from 9 to 6
move 8 from 1 to 8
move 1 from 5 to 3
move 1 from 3 to 4
move 1 from 1 to 8
move 13 from 6 to 3
move 9 from 9 to 5
move 1 from 2 to 8
move 8 from 5 to 1
move 1 from 2 to 7

70
2022/05/main.py Normal file
View File

@@ -0,0 +1,70 @@
import itertools
import re
from utils.input import read_input_lines
class Instruction:
def __init__(self, line: str):
parsed = re.search(r"move (\d+) from (\d+) to (\d+)", line)
self.moved_count = int(parsed.group(1))
self.from_column = int(parsed.group(2)) - 1
self.to_column = int(parsed.group(3)) - 1
lines = iter(read_input_lines())
initial_stack_configuration_lines = list(itertools.takewhile(lambda line: len(line) > 0, lines))[:-1]
instructions = [Instruction(line) for line in lines]
initial_stacks = list()
for line in reversed(initial_stack_configuration_lines):
for stack_index, character_index in enumerate(range(1, len(line), 4)):
crate = line[character_index]
if crate == " ":
continue
for i in range(len(initial_stacks), stack_index + 1):
initial_stacks.append(list())
initial_stacks[stack_index].append(crate)
def copy_initial_stacks() -> list[list[str]]:
return [stack.copy() for stack in initial_stacks]
def print_stacks(title: str, stacks: list[list[str]]):
print(f"Top of each stack in {title}: ", end = "")
for stack in stacks:
print(stack[-1], end = "")
print()
stacks = copy_initial_stacks()
for instruction in instructions:
for _ in range(instruction.moved_count):
moved_crate = stacks[instruction.from_column].pop()
stacks[instruction.to_column].append(moved_crate)
print_stacks("part 1", stacks)
stacks = copy_initial_stacks()
for instruction in instructions:
taken_crates = list()
for _ in range(instruction.moved_count):
taken_crates.append(stacks[instruction.from_column].pop())
for crate in reversed(taken_crates):
stacks[instruction.to_column].append(crate)
print_stacks("part 2", stacks)

1
2022/06/input.txt Normal file
View File

@@ -0,0 +1 @@
cdhccdbdggfjjgssjzjzggjnjpnpbbzbnzzflfjfnfrrpvrvbrvvrvggvlvnnbrnrcncsnndbndbnndbdndfdrdvrvvndvvbggnrrnbrnntffgttwzwnnmvmcvvhsstzzlnlwlttbzzpnpmnnjvjnntmnmfftwwrfwrwswmmfrrfrrgbrbffwvvshvhrhmhththbbmqbmqqlslhssrmmqdmmjtmtmjtmjtttnwnvwvqwqjjnbbbdbqbnbpnbnllglcglcgcdczdznnqhhfthtmtlldqlqrrmddrldlzdllvddjcddqfqbqsbqqnllwppqpqzzrbbdppzsppjdpdqpdqdfqfrrwbwrwwqcqcsqsvvpbvbbztzptzzpccdtdhdffvqvcvzzmwzwddjfdffplplqlvlmmmvggpmpvpddpbptplpvlplvpvvnrvnnbqqqjhhwfhwfhwhqhmmpphqpqvppfzpzjzddgzzwffjmjggwhwwnnmlmpmmhcmcpcrcddvzvpzzwnznfznffgdgvddvtvgvsvdsdbbjnjtntbnttgbbbvgvgrgrzrvzrzddlsddcndcnnfqnnmpmlppdlplzplzpzgzmzmddlvlnnbttbwwhbhdhfdfssjppmcpplpdddnpdnnljlwjljsjnjhnhvhvqqsffrbbdttjdjndjdwwsfspffnhfhhlvhvmmqjmmwzwszwwvdvpdvdbdtdsdtsshvvmtvmtmctclchccrllznzfffpjjvhhdmhhvphpghgsgmmhlhnlnmnlnslnlgngznnsqnqddllpwllmzmjmttptfpplglqlgglgqqptqqmvmtmjmddcchbblltslsvsmvmgghmmccnzcztczzmnmttrdrvvcvzvvzllbhllnldndbbqffbbgtgddbtdbbzttdptpccjnjppbllbzlblrlcllhrrhqhgqqbcqcvcdvvnnzfzvzttrptrrwmrmlrlddvttdbtdbdcdvccwlcwwhphmppwfppclpcllgqgnghhvfflfggrzrcchfhhrdhrdhdnhnmmhjjwqjjpmmwvmmdnmnzzqmqwwmtthtdhtthnnqhqdhqqndqqwffsbspbptpmmndnllsmmdhmhfhnhjhghshlslppbgpgngddlsljsjmmzqzhhswhssfzssfqqcmqcmqcmmqggjcjvvgssrccwddmpmwwdfdpdbdpdwdvvqfvfrvvvsbvbhvvmqqcjqqvzqzppncnhhqnnpgplpqqpjpbblpbbbshsthhvfhfmmqzmmznnvrvqrrwdrdlrlwlttzqttjvttqltqqnfqqqwjqwwqttfstftjffsqqnhhnsnqqhggbsgghfgglslmssqlqhlhthqhccdsspsnssshbbnmngnnhllwclcffqllsrszrssnqsqvqjvjcvcttqgqbqmmfqfsqfsqswwvcvffndnfdfvfcvvggsmsfmfwfpfwwzhznntgtlglmmlfmllwrlrwwhcchqchhznzjjcdjdbjjhcjcscwwlnnsgngqqtgqgngnwgnnhqnnhchmchhtchcnclcmccgffbmmzvvrnngwwvddzccnjntjtwjwwztwtmtddjddpsptpbpbvvbwwnlnmndmnmdnnclnnbsbddpfdfvvjtjqqtqqqzjzlzqllzzwwlppvfffpcffffprrncnnzsnznhhwvvqhqphpjjgqqvnnmdmqqglqlblgglrlsspscsjjpvpbpjjwccslsppdjpdjjwvjjmhjhtjjwqqbqjqzjqzqpqbbswwlssqzssbjjpjqjbbjcjpjspjssjjzhhhnjhnhbnhhwzhzwlcshqlqpzgggzmcwntcwmfgtrwwjdpnbdqqcgnzgbdrzdmpwgvtvqffqbpvjpjrcfswffllnvnwvhclpjcwqwgnwqwvwsfgflrgzzsswffwjdjgvdvlgmczcbthwbvhggwzwlzfmhvwvjpbpnhcczbgfhhgghsmjwnvnsvnvmqwstrgnncwbqgbqpgdngllcqnzgwswpgtwzgqzggnzsdgltrlqfctqfvlzdswccfpdtjbfnrbqsmpjclnplbmqbmvwbzzdflwbqrljvzjpcrmnqsmrpqlmfsgcmthqpwgwzvmrjnhqczljcpnzjbwzrhjrzmcqpmlbzhgmqrlzsjbjsvcmcngptzlrthwsrjrlmsrgjlzrvpzwmprwnpgvjtspsppfvwfwcvbnqcwwmzlbqthqmbnbmnsnzgsbbnqtrvhlzjhphclpjzrdblszrnftqgwwrhpznhjhgrncvsvrmtmmgssvzddjfrnrzhbrqrfffjvzrqdnrdbvjwgrvlcpbncfgczlwdggsjmwzhndcdbggjvwfljctjnsjwczwfdrfttbhnlswfdbpcnwpspdhnzwqbgdswwpccbpfpgmfmvvwpzbzqsbbjbfnhjpszcbnrdplmwtdjtpcsztdjcmczltnstzwlcdbtdhsdgsgtlvdfqggfmmrppjfrmtfwhpbjsppszjbhmthndqmvbmqcbtqsltwrcvlvblwspbgspjftwllzcmnsrvjpnstzrfmcflnhppsdfggwbzvnvlnjqlfvrlplnzvfrwvgcgqvnpfgtgchctvhcplclzmfpwgnfhqjgglfmsgpflqcpqmbbhwnvvdllcnhblpnndbdtmgvfbvvvlvzlrpfqmnvzbfrssjtlgcjtpfznshvdjrjnfshfcgvwcdbqlfsbhnzwmsgwhpbzttgfjsqgwvdmbdwjljhsndrbbzfrsqjhcbldzqpmtnfvnmzltjcrvrltwshnhqlnclmcnfpbzstsczlqmfmdftzfbcwqnhqppzfbzpbfjhmmtvtbmblmtshsbtjlvsqvmbmgstbbdmhprqmtpfdqqntmnlbmpsmwfgrvstjcllhwpcddnljdjvdrbwqmgrjnldpgnrhgqpzqrvwzsngrgnbpjnsffzjsbdptwnnfcqlscfhvggpfstsnqzcjbqqhgdpqsrlprcppgqmddpqpbnvgwtdqsbbgtvsqfrtqfsbdzhsztfmvwrrsjcbtcjgzrnhnpgldtwbwgmwbgmjjzsbbzlhgmlczrhjwtzrgwscmjvlstprldhglvftqzbtrmcwzgtjppbnjcdvjvcwvdbngnbrmjvvtnwdqfclbpgzcfnnnlnngtgmhsqsdmbjctjzjpbrwrhscqshmmwbtfnzjgsrjlnqqdsvdrjdzsdprphnfmwwcztqfcrjvnfhlvnqwbrfmcvhrbtgvcrqjjfcnzwmlfzzdcbbzvphhmsdltwjfdcgthpvszqzjdbfwrpvhbjqdhrscnvjhjvvcldnhgjclmzpbrrwnscgpcqrpdgsnjnwhctcdqgwqbrcszfzpmtdrhlftvwffdjrtznqrppqbdbwvzmtlpvsqqpcngjgfdrpngnspdwhhvlhqrtsphgqrlldggtrvqsprbfdmrpgcmqphdvjfmhlznpgtqlvtnllcdhzhhtjjlfvdlwhcrfmjmdjtmbllvsfgvmfqtqlmrlrjmqptszvjdpzhphppljnpjdjpwlrclssgdnstchhwhpflmlrtdqvqbbljrmnflrltzpqmgqfrczvfzrpfsrwsgpljvjfjdjdvjchcdmmtjgghqspwzdtwqgtvmnrrbfbgnhcrvnzznrdlqmgmdwmpwzlqdjtvpszwnjtjtmjqvfwvftlhgpvgzswpbvbllfcwpjnsmbhzrdpdzjsrpnhphdcqjmzvvhrjcwhgwjwcshqwzpbpmfnjjvqcjrqmvsrdrtdvfhwhrbpvrqrsfzflslqtdrtcsggtzmpvbszdgttlvpwwltvpcwqmnwqtpcfzgsvsmncvpqqdrljfwtncplmjlpfcnqmcctwzhrbmrfwvsrjsbnhjrjmrnbmmnnhsvlltwzzhsgwppnlmljgpcsmpchdjdzpgvrtwsfzffhnlbfmrldzbshvpqhnfzpwnvczgfvhbntcpztwqlfgtsmdhvcrgjhvqrhbpvbpzcpbgzrcfjztbnfjptbzfpztwprwf

20
2022/06/main.py Normal file
View File

@@ -0,0 +1,20 @@
import collections
from utils.input import read_input_lines
input_sequence = read_input_lines()[0]
def find_position_with_distinct_characters(count: int) -> int:
buffer = collections.deque(maxlen = count)
for i, c in enumerate(input_sequence):
buffer.append(c)
if len(set(buffer)) == count:
return i + 1
return -1
print(f"Found start-of-packet marker at: {find_position_with_distinct_characters(4)}")
print(f"Found start-of-message marker at: {find_position_with_distinct_characters(14)}")

991
2022/07/input.txt Normal file
View File

@@ -0,0 +1,991 @@
$ cd /
$ ls
dir blrnnv
dir ctfjwl
dir dqf
135993 dqqbcfr
dir ftj
125510 fzjdz
dir jvtlfbzr
31762 lsvw.lwr
dir qfstpm
dir sbprmc
dir svbnljr
dir tchbjclg
dir wtm
dir ztrz
$ cd blrnnv
$ ls
169869 mjjj.wnq
$ cd ..
$ cd ctfjwl
$ ls
209537 zzdpcnmt.qbf
$ cd ..
$ cd dqf
$ ls
205200 hnbqlmmg
80316 lmw.zmd
dir mwj
122312 tsrwvqbg.tzh
$ cd mwj
$ ls
18195 bddslhrg.twf
122813 qfccg.crl
$ cd ..
$ cd ..
$ cd ftj
$ ls
dir clchr
dir hmd
40232 vtzlv
$ cd clchr
$ ls
dir sbzf
$ cd sbzf
$ ls
257770 thwhz.pgp
$ cd ..
$ cd ..
$ cd hmd
$ ls
62643 bddslhrg.qzl
dir lfpm
277745 sgddpc
117478 vjchlsrc.cmh
7911 zzdpcnmt.qbf
$ cd lfpm
$ ls
107158 bddslhrg
253844 fzjdz.mlw
217005 glzsnz.cvs
71371 qfccg.crl
193163 sdmmmds.nwt
dir vlnbm
$ cd vlnbm
$ ls
143113 lwhtsvg.bjm
$ cd ..
$ cd ..
$ cd ..
$ cd ..
$ cd jvtlfbzr
$ ls
dir gwz
dir hfftvmw
dir jlftgw
dir nnpvwtvt
98713 wtbzpqvb
$ cd gwz
$ ls
161853 blfnwqtm.vhw
180524 fbqpql.bbw
dir jvrdcf
dir ldcmtwvt
dir pjm
dir qjj
$ cd jvrdcf
$ ls
42681 bddslhrg
dir cbcq
dir fzjdz
dir ghwnd
dir gpbhtj
dir hsmlb
dir mjjj
129934 sdmmmds.nwt
dir wdvqhn
196970 zzdpcnmt.qbf
$ cd cbcq
$ ls
dir hsw
262458 lbhzblh.zfn
dir qbpvrr
205708 sdmmmds.nwt
263842 tqcgmwbj.bcn
4847 vjchlsrc.cmh
72550 wnmpdtrr.zrc
$ cd hsw
$ ls
dir rdvfwbw
$ cd rdvfwbw
$ ls
dir fthdrqnr
$ cd fthdrqnr
$ ls
31974 htnpjdr.wsl
$ cd ..
$ cd ..
$ cd ..
$ cd qbpvrr
$ ls
198987 nnhpdvv.vvn
$ cd ..
$ cd ..
$ cd fzjdz
$ ls
149832 ldb.qnt
183866 nbnzfplj.lrs
$ cd ..
$ cd ghwnd
$ ls
177598 ggchv.tsv
163367 mjjj
13258 pdcf.flm
$ cd ..
$ cd gpbhtj
$ ls
dir cvm
160598 fcng.sbf
272547 ndnlzb
285657 pvs.ldf
166261 sdmmmds.nwt
207433 zzdpcnmt.qbf
$ cd cvm
$ ls
246462 fpwvfs.gpb
133303 vjchlsrc.cmh
$ cd ..
$ cd ..
$ cd hsmlb
$ ls
252425 tqcgmwbj.bcn
$ cd ..
$ cd mjjj
$ ls
96351 fvgj
272667 qfccg.crl
196309 ssv.ljs
$ cd ..
$ cd wdvqhn
$ ls
190200 sdmmmds.nwt
dir tjgfcs
214364 tqcgmwbj.bcn
174218 wqpmmgtd
$ cd tjgfcs
$ ls
dir gngb
268455 hqctmf.cdg
242060 prbwvv
$ cd gngb
$ ls
102313 fhqgpb.cqc
77189 mjjj.cdw
163701 sdmmmds.nwt
$ cd ..
$ cd ..
$ cd ..
$ cd ..
$ cd ldcmtwvt
$ ls
dir bqmbrr
dir cfcfnspz
dir fzjdz
dir gvd
dir mpqtgd
9560 mqfdcz.wqt
75810 shps
249000 tqcgmwbj.bcn
139099 zdv.zgz
dir zpct
$ cd bqmbrr
$ ls
175893 hwrdtwsv.brd
$ cd ..
$ cd cfcfnspz
$ ls
dir gmzsn
dir gvrfbt
105314 mjjj
181873 vjchlsrc.cmh
$ cd gmzsn
$ ls
dir bddslhrg
$ cd bddslhrg
$ ls
dir cspptmpm
258841 fzjdz.bfs
dir npmh
72584 qfccg.crl
$ cd cspptmpm
$ ls
239223 fzjdz
11003 sdmmmds.nwt
73589 tqcgmwbj.bcn
251204 vdz.jcd
$ cd ..
$ cd npmh
$ ls
186878 bddslhrg
264830 bddslhrg.gdq
$ cd ..
$ cd ..
$ cd ..
$ cd gvrfbt
$ ls
200067 zcvjj
$ cd ..
$ cd ..
$ cd fzjdz
$ ls
dir bddslhrg
dir fvqszrj
dir gqcdtjzj
dir pcfr
250120 pqqbpmr
dir qbpvrr
$ cd bddslhrg
$ ls
72852 sjn
$ cd ..
$ cd fvqszrj
$ ls
dir mmzcqr
24439 tqcgmwbj.bcn
dir vhpqjr
$ cd mmzcqr
$ ls
dir gzfqggrr
$ cd gzfqggrr
$ ls
162528 frdgcr.gnb
$ cd ..
$ cd ..
$ cd vhpqjr
$ ls
194144 mjjj
$ cd ..
$ cd ..
$ cd gqcdtjzj
$ ls
231917 pftb
174091 vbzfgtwp
$ cd ..
$ cd pcfr
$ ls
dir dtbws
76624 qfccg.crl
dir qjqjd
dir qjsldd
$ cd dtbws
$ ls
dir vwjnsbjm
$ cd vwjnsbjm
$ ls
56502 mjjj.jqj
130426 qfglmz
23199 vjchlsrc.cmh
$ cd ..
$ cd ..
$ cd qjqjd
$ ls
71015 qfccg.crl
40443 vjchlsrc.cmh
$ cd ..
$ cd qjsldd
$ ls
261945 fzjdz.vcw
$ cd ..
$ cd ..
$ cd qbpvrr
$ ls
138915 fvh.sdp
dir mdvqv
168843 qbpvrr
90599 tchbjclg
226671 vjchlsrc.cmh
$ cd mdvqv
$ ls
159050 bddslhrg
2691 fzjdz
245322 psr
7732 zhnbgcc.lsc
$ cd ..
$ cd ..
$ cd ..
$ cd gvd
$ ls
84112 bhnt.gjg
18231 gzrgd.vvj
dir ntvmrrd
234773 rcfbjzj
281805 sdmmmds.nwt
267837 zzdpcnmt.qbf
$ cd ntvmrrd
$ ls
46209 lwvvwd.rtg
$ cd ..
$ cd ..
$ cd mpqtgd
$ ls
99833 qbpvrr
$ cd ..
$ cd zpct
$ ls
dir bddslhrg
272296 znffshsg.jrt
$ cd bddslhrg
$ ls
81585 vjchlsrc.cmh
$ cd ..
$ cd ..
$ cd ..
$ cd pjm
$ ls
147674 rbctzb
$ cd ..
$ cd qjj
$ ls
21770 wtht.fpd
$ cd ..
$ cd ..
$ cd hfftvmw
$ ls
dir bhvzrsv
130208 cclgndpd
dir fzjdz
39285 jtmcp.pjv
dir mbgvdmpp
dir tchbjclg
202920 vjchlsrc.cmh
$ cd bhvzrsv
$ ls
167049 bts
dir mjjj
257434 qsrpmshg
279724 sdmmmds.nwt
149934 snpb.zwq
254808 tqcgmwbj.bcn
dir wgf
$ cd mjjj
$ ls
dir mrlvp
$ cd mrlvp
$ ls
197237 pmwjbf.lmn
$ cd ..
$ cd ..
$ cd wgf
$ ls
77157 zzdpcnmt.qbf
$ cd ..
$ cd ..
$ cd fzjdz
$ ls
77499 mjjj.pdq
dir shrpdcg
180282 zzdpcnmt.qbf
$ cd shrpdcg
$ ls
22528 bddslhrg
191369 mjjj.llb
35213 sdmmmds.nwt
131772 spfmhdpf.wtr
284434 tpzg.qjg
$ cd ..
$ cd ..
$ cd mbgvdmpp
$ ls
220250 fsdzqhc.ljm
101355 vnrcwb
$ cd ..
$ cd tchbjclg
$ ls
113952 gjbp.qgs
$ cd ..
$ cd ..
$ cd jlftgw
$ ls
dir bddslhrg
210047 cdbch
dir dvrb
266336 fhvwlg
139851 qfccg.crl
dir rcqhb
176510 vjchlsrc.cmh
dir wfrjg
$ cd bddslhrg
$ ls
78175 zzdpcnmt.qbf
$ cd ..
$ cd dvrb
$ ls
216103 fzjdz.blg
$ cd ..
$ cd rcqhb
$ ls
39727 cgfjm.dpt
dir pwb
$ cd pwb
$ ls
39040 sdmmmds.nwt
$ cd ..
$ cd ..
$ cd wfrjg
$ ls
206877 zzdpcnmt.qbf
$ cd ..
$ cd ..
$ cd nnpvwtvt
$ ls
264455 czrjz
dir nfdv
dir nmcp
113232 pffgw.hbv
dir qrzlrt
$ cd nfdv
$ ls
dir fpldng
dir jhj
56720 ltv
170870 rgvs.ggh
$ cd fpldng
$ ls
157283 vzv.qrq
$ cd ..
$ cd jhj
$ ls
172487 qpfh.lpr
$ cd ..
$ cd ..
$ cd nmcp
$ ls
273633 zzdpcnmt.qbf
$ cd ..
$ cd qrzlrt
$ ls
111080 bddslhrg
$ cd ..
$ cd ..
$ cd ..
$ cd qfstpm
$ ls
92950 hjr.zjn
252254 sdmmmds.nwt
$ cd ..
$ cd sbprmc
$ ls
dir bddslhrg
158704 bgnt.vbd
dir cddp
dir cpf
dir hfns
276655 phcccdq
dir qbpvrr
dir srjpcj
55405 vhb.mbj
$ cd bddslhrg
$ ls
238260 mjjj
$ cd ..
$ cd cddp
$ ls
87685 fzjdz.sbz
$ cd ..
$ cd cpf
$ ls
dir tchbjclg
$ cd tchbjclg
$ ls
dir wjcvfvz
$ cd wjcvfvz
$ ls
280711 svmf.czw
$ cd ..
$ cd ..
$ cd ..
$ cd hfns
$ ls
dir bbjnrhf
dir cvjtpc
101075 ddbml.vff
dir gdlqtlv
157960 mswfp.wcj
187182 qddfchn.dpg
59533 rfjvzcq
47332 wszmlq.nbt
$ cd bbjnrhf
$ ls
269590 dgmjpzcz
dir mjjj
84955 mjjj.jqn
dir mwqvvsnt
dir qbpvrr
dir qtdmwqcj
131930 tqcgmwbj.bcn
dir vvwb
$ cd mjjj
$ ls
dir hvvh
$ cd hvvh
$ ls
235980 vmmvp.sbh
$ cd ..
$ cd ..
$ cd mwqvvsnt
$ ls
242698 mjjj.qbm
15137 rncwrgjl.jfr
158528 sdmmmds.nwt
$ cd ..
$ cd qbpvrr
$ ls
dir gpc
$ cd gpc
$ ls
184310 lqfgplfg
$ cd ..
$ cd ..
$ cd qtdmwqcj
$ ls
30238 cfpng.fnl
284340 gst
dir lvcjcglg
82263 twmnlqcq
78023 zzdpcnmt.qbf
$ cd lvcjcglg
$ ls
225027 lsdrg.wqv
$ cd ..
$ cd ..
$ cd vvwb
$ ls
184590 trg.vmc
156231 zzdpcnmt.qbf
$ cd ..
$ cd ..
$ cd cvjtpc
$ ls
dir whqnlc
$ cd whqnlc
$ ls
66362 jnsprdt.vrs
dir tchbjclg
dir zhw
$ cd tchbjclg
$ ls
227846 vqjtc.pld
$ cd ..
$ cd zhw
$ ls
dir bgwcrp
$ cd bgwcrp
$ ls
114175 dftv
$ cd ..
$ cd ..
$ cd ..
$ cd ..
$ cd gdlqtlv
$ ls
121215 gbltpcv.prz
41387 tqcgmwbj.bcn
$ cd ..
$ cd ..
$ cd qbpvrr
$ ls
79921 tqcgmwbj.bcn
263185 vjchlsrc.cmh
$ cd ..
$ cd srjpcj
$ ls
106650 fzjdz.tdf
135245 qfccg.crl
97014 tvlmvqm
$ cd ..
$ cd ..
$ cd svbnljr
$ ls
286919 lwvw.zlr
$ cd ..
$ cd tchbjclg
$ ls
dir bljmjwm
dir hsjww
dir ptfsh
dir qbpvrr
147832 qfccg.crl
$ cd bljmjwm
$ ls
dir cqtmhzbf
dir mfpcdbg
dir qlzg
dir qtdh
dir tbdff
dir tchbjclg
211603 zhr.gwl
$ cd cqtmhzbf
$ ls
dir mmbgqlm
150758 tqcgmwbj.bcn
dir ztcbmbw
$ cd mmbgqlm
$ ls
93439 bddslhrg.gnm
25644 qbpvrr.jhm
$ cd ..
$ cd ztcbmbw
$ ls
dir cmwwg
dir stgmndfd
$ cd cmwwg
$ ls
239158 bfl.pwl
dir dbvnwz
17700 pqtpmpp
dir tchbjclg
$ cd dbvnwz
$ ls
217821 bzgsbc.zzp
$ cd ..
$ cd tchbjclg
$ ls
dir tpdtglwp
52714 vjchlsrc.cmh
111040 zzdpcnmt.qbf
$ cd tpdtglwp
$ ls
287567 jmddscd
$ cd ..
$ cd ..
$ cd ..
$ cd stgmndfd
$ ls
38426 bll.pww
$ cd ..
$ cd ..
$ cd ..
$ cd mfpcdbg
$ ls
dir trjgzcj
$ cd trjgzcj
$ ls
dir hngr
268655 lgrwtch
258843 pbpnjf.tmg
100112 qbh
72784 qbpvrr.cpg
dir vbmqtf
197735 vjchlsrc.cmh
$ cd hngr
$ ls
82873 cwbmqp.llb
261780 hsgwfv.pfn
42859 ljt
dir tchbjclg
$ cd tchbjclg
$ ls
dir fhsgvttf
253131 gtghn
dir nzpcvjhp
dir tpqrqtqj
$ cd fhsgvttf
$ ls
56727 mjjj.vzf
$ cd ..
$ cd nzpcvjhp
$ ls
dir bddslhrg
dir blhrls
$ cd bddslhrg
$ ls
242433 vpvpqtqb.dfr
$ cd ..
$ cd blhrls
$ ls
110313 fzjdz.qtf
$ cd ..
$ cd ..
$ cd tpqrqtqj
$ ls
dir dfjmpvj
114636 gmqqrtv
dir mjjj
175067 wggfznff
$ cd dfjmpvj
$ ls
174485 sjzg
$ cd ..
$ cd mjjj
$ ls
111397 pslm.fjf
$ cd ..
$ cd ..
$ cd ..
$ cd ..
$ cd vbmqtf
$ ls
151429 tchbjclg.tzm
$ cd ..
$ cd ..
$ cd ..
$ cd qlzg
$ ls
127640 bddslhrg.wbj
dir fzjdz
dir ghllcw
62733 qfccg.crl
96986 qwgh
268380 vjchlsrc.cmh
$ cd fzjdz
$ ls
153535 gcjss
$ cd ..
$ cd ghllcw
$ ls
dir fzjdz
dir hwfm
2536 jglh.njg
dir mjjj
dir mlhwcg
200842 qfccg.crl
dir tchbjclg
246542 tqcgmwbj.bcn
dir tqtsl
dir vpn
$ cd fzjdz
$ ls
124920 jzsbrwj
dir wtvfgcrq
$ cd wtvfgcrq
$ ls
dir ltnzjbl
187917 mjjj.svp
dir nvgrzrbr
dir pngcwl
$ cd ltnzjbl
$ ls
151460 jmc.zjf
252590 tchbjclg
$ cd ..
$ cd nvgrzrbr
$ ls
193994 qbpvrr.tsv
152776 tchbjclg.swm
243770 vqzs.hjp
$ cd ..
$ cd pngcwl
$ ls
74603 bddslhrg
288915 vjchlsrc.cmh
$ cd ..
$ cd ..
$ cd ..
$ cd hwfm
$ ls
dir qbpvrr
92630 vjchlsrc.cmh
$ cd qbpvrr
$ ls
dir vlwbhgnv
$ cd vlwbhgnv
$ ls
5248 tchbjclg
$ cd ..
$ cd ..
$ cd ..
$ cd mjjj
$ ls
255751 qfccg.crl
$ cd ..
$ cd mlhwcg
$ ls
115287 pfmch.ncr
$ cd ..
$ cd tchbjclg
$ ls
dir jgrmrzlh
155900 jpljl.fnw
$ cd jgrmrzlh
$ ls
dir mjjj
96116 qbpvrr
270714 tqcgmwbj.bcn
$ cd mjjj
$ ls
59415 dpdgtz
47363 twghmhf.qhf
194434 vbnppl.fws
$ cd ..
$ cd ..
$ cd ..
$ cd tqtsl
$ ls
34243 qqf
131945 qtplsbwd
$ cd ..
$ cd vpn
$ ls
286479 sdmmmds.nwt
$ cd ..
$ cd ..
$ cd ..
$ cd qtdh
$ ls
215668 nhfpn
$ cd ..
$ cd tbdff
$ ls
48347 qfccg.crl
178091 vbsqcnmm
$ cd ..
$ cd tchbjclg
$ ls
dir bddslhrg
dir cwn
251313 hll.ctt
dir qbpvrr
dir scsp
$ cd bddslhrg
$ ls
dir pqtj
185542 qbpvrr
dir tchbjclg
$ cd pqtj
$ ls
141015 jtwpnb.wvf
17260 lgvbns.pvt
$ cd ..
$ cd tchbjclg
$ ls
dir btsmnvn
237149 hhgbtf.zzs
258581 lwvfgbdj.gpp
31561 mjjj
240514 qbwq
90283 qfccg.crl
$ cd btsmnvn
$ ls
dir bddslhrg
dir qbpvrr
$ cd bddslhrg
$ ls
144007 tchbjclg.qql
$ cd ..
$ cd qbpvrr
$ ls
211075 mjjj
$ cd ..
$ cd ..
$ cd ..
$ cd ..
$ cd cwn
$ ls
67908 gldrw
231112 qbpvrr
$ cd ..
$ cd qbpvrr
$ ls
4482 fzjdz.lzr
134244 rnscgpv.tvg
211213 tmvzclz.mjg
107771 wvzs.nns
$ cd ..
$ cd scsp
$ ls
30654 zzdpcnmt.qbf
$ cd ..
$ cd ..
$ cd ..
$ cd hsjww
$ ls
12233 crzr.jrf
dir qbpvrr
$ cd qbpvrr
$ ls
dir bddslhrg
54681 fzjdz.wzv
212670 hpmzrq
dir mcvbjw
138779 nhsdjmjj.szh
dir nllvlzfr
217275 tqcgmwbj.bcn
$ cd bddslhrg
$ ls
261081 lbdqrjjp.ffj
244506 wvn.ttr
55843 zbng.zmm
$ cd ..
$ cd mcvbjw
$ ls
149468 rcvbqhh
$ cd ..
$ cd nllvlzfr
$ ls
162791 rdrhrnzc
$ cd ..
$ cd ..
$ cd ..
$ cd ptfsh
$ ls
163959 bddslhrg.wwb
dir hthjj
dir hwpv
222930 ndvqsfbs.rfb
dir rgrcfr
dir rvrsrfl
95254 tqcgmwbj.bcn
282463 vjchlsrc.cmh
181699 zzdpcnmt.qbf
$ cd hthjj
$ ls
101683 dthb.hwv
112759 mjmdfgl.vdz
191795 whtfg
$ cd ..
$ cd hwpv
$ ls
244334 fzjdz.pgp
$ cd ..
$ cd rgrcfr
$ ls
dir wpslpf
$ cd wpslpf
$ ls
87578 mjjj
$ cd ..
$ cd ..
$ cd rvrsrfl
$ ls
dir qbpvrr
$ cd qbpvrr
$ ls
dir gqv
dir hfg
dir lpbc
dir ppp
16805 snlhrz
29365 wnd.mdj
$ cd gqv
$ ls
229300 tqcgmwbj.bcn
$ cd ..
$ cd hfg
$ ls
1680 hcmmjtbq.wcv
$ cd ..
$ cd lpbc
$ ls
100372 lqf
88156 sddtdz
$ cd ..
$ cd ppp
$ ls
79608 tchbjclg
$ cd ..
$ cd ..
$ cd ..
$ cd ..
$ cd qbpvrr
$ ls
22955 zzdpcnmt.qbf
$ cd ..
$ cd ..
$ cd wtm
$ ls
4584 qfccg.crl
$ cd ..
$ cd ztrz
$ ls
187968 fzjdz.thw

85
2022/07/main.py Normal file
View File

@@ -0,0 +1,85 @@
from typing import Optional
from utils.input import read_input_lines
class Directory:
def __init__(self, name: str, parent: Optional["Directory"]) -> None:
self.name = name
self.parent = parent if parent is not None else self
self.child_directories = dict()
self.child_files = dict()
self.total_size = None
def record_directory(self, name: str) -> None:
if name not in self.child_directories:
self.child_directories[name] = Directory(name, self)
self.total_size = None
def record_file(self, name: str, size: int) -> None:
self.child_files[name] = size
self.total_size = None
def get_size(self) -> int:
if self.total_size is None:
self.total_size = sum(self.child_files.values()) + sum(child.get_size() for child in self.child_directories.values())
return self.total_size
def collect_directories(self, target_list: list["Directory"]) -> None:
target_list.append(self)
for child in self.child_directories.values():
child.collect_directories(target_list)
class Session:
def __init__(self) -> None:
self.root_directory = Directory("/", None)
self.current_directory = self.root_directory
def handle_command(self, command: str) -> None:
if command == "ls":
return
(left, right) = command.split(" ", maxsplit = 1)
if left == "cd":
if right == "/":
self.current_directory = self.root_directory
elif right == "..":
self.current_directory = self.current_directory.parent
else:
self.current_directory = self.current_directory.child_directories[right]
def handle_listing(self, size_or_type: str, name: str) -> None:
if size_or_type == "dir":
self.current_directory.record_directory(name)
else:
self.current_directory.record_file(name, int(size_or_type))
session = Session()
for line in read_input_lines():
(left, right) = line.split(" ", maxsplit = 1)
if left == "$":
session.handle_command(right)
else:
session.handle_listing(left, right)
all_directories = list()
session.root_directory.collect_directories(all_directories)
total_size_of_interesting_directories = sum(directory.get_size() for directory in all_directories if directory.get_size() <= 100_000)
print(f"Total size of interesting directories: {total_size_of_interesting_directories}")
total_disk_size = 70_000_000
needed_free_disk_size = 30_000_000
current_free_disk_size = total_disk_size - session.root_directory.get_size()
minimum_folder_size_to_delete = needed_free_disk_size - current_free_disk_size
size_of_deleted_folder = min(folder.get_size() for folder in all_directories if folder.get_size() >= minimum_folder_size_to_delete)
print(f"Size of deleted folder: {size_of_deleted_folder}")

99
2022/08/input.txt Normal file
View File

@@ -0,0 +1,99 @@
003112220410413101104044022234320204233341435252223642044225451531421012104343030211442433410302111
301233004003313130222434121135033231250505241131342032404032560542233000343455552123100410402211201
111301041221333142533352050250154136146324550411565615444115604102531135302000320033233340431313123
011312210420442043155233305201305643445224334303310253225205601265233454400214114322131420224022313
130102441231200141254202121022423405224443210463250415204410624313613034320040015223211432442333110
133121132322223054104323242043651144066341346000104210124535555236324451132555525220523220023202433
110011123024113203143145243605143331512223606564503661350336662505131254503242354031400131012444222
221400422202335053520044325014041432662161415523526711633662600635304000112322014001533351130303321
030222020044115331004065013253364503664435753416641653716424535324654054023321025154331103034342414
030331241153233040140314112524504535172167445223426653152774166352145410064425434012002122431142343
224111232453145423354550035141103644127571711431336236226321752314754510214316215104550522141301020
424321022432003551434012134531644165753146143232242275633762323631713541330463531053004424012234010
221233440041435131321565604060121637542135243721227576264551457171313165211546132314103242442012133
301320232222024200651041405631257577625236256225367443317773421262762172454463051224654015452230401
124314451244222611016300517414362722551374735555353871173242751564427674344212032442221554524035432
000210412345203005364660077252742673773341654558568632445755573574757433452636410261362004114032013
333130514223252440150314572132443233363783556666363566733363262631651361523573335361463232143300044
400403124212626240015541437753711632635435857234865883574647337436376563235264524230225211320425534
430312520241033613150127256341412352564548243842255622454762832274857163157242366022041262252034150
125211521340246341461723355443362487532437274863758283488567453538667642367654751321503343220351304
015045453331430626273664314125778234645658386774837783464366334264476243327176571544650404453253132
354034323663213666746174754737374552772744668787244468236435632534753452366177147233020313054042345
305241054630156250416544221136444247327848337737584777837244467756426322644474332262330430251551212
100144030632532041231474166555527386344645548655948476835366757558682728623657547471260405014131510
155501551351164622444476154658383338677369856795967346765977585753438378656352723127554031451225340
213252046404053134327512554784653544697439375473948735593644477348334755453317243676612665133404310
022440140420166534174335264388542568833984445757393864997986883894574577853347367415453352646352541
303425632364032563633467847288735478557676734393879573848466463466672455482853676764477400452414425
421140260266576264621526686828328833799894373434775335763857585383998562862724435337211515426106224
251234063153345361761483764445395779384568938899876568577359785776678952473247274437226445141011143
124165362100637756715727365876646574835535677777467785479666667584536895483528343623556220650044411
523533116461715454347526758528694839737349689796485884675949699354664766465728468324363766204426020
011655232111314171647378426863359767797699886798595874554677869353593448485338287251255363024600501
201454444103773472628888556987787587788889498545597569965587748496753787964648276727241677205552530
022050015673621733475438774338498584975649879876857968775687577968447843939528275674512475556245535
415145246426622536566872225778388854879897849855475687687595454675468637795674534385355242230005213
515410462156777244275234668693874665788796767699675757959578987749863457937753862877526274731341533
532441044352764132482273798897585496755464759898898996955476545867443535986538526852746625533463346
042116466642255478273735578633656564997786577695957789988869999965866866547392358543326526744105124
305463642721567264236826357995536786844968968785757997557699474697669835738584868845834527260231552
066231251534151145564875937345768799895756579656987695996797768779596848379994862646436522463360266
506513057363414584637639439854956668854878865987777598756576697549657897644947484484534264535522136
131666244551736787837659743739478747677995596779697659755568679946768553647438363837764527562663652
424404413335566473356634745356959967996577965786978695878778775749964899347635788855331715645156443
366410447316422733452686338845457787759555776998978979667795556665499755678449775626855353212651324
302136251253517685366593955978666557656668675898896669776695986549696689467499828826265743355612425
546506521534743584874443398869667685788797956777788696997955989646664668879679457843885333126334344
362262154313747445367249673496655464765879658679769897687679766789496785648597346877862642316202103
026226125354532563527338467655476495659657769687899897897899856576869585587683926347427571714351012
324246031677535478765836973778855888768885696676889798687785885666785975868394627754287365751563132
031351623136767474878299634934847976977866799698978866969865695657475657893553946224747277645245120
026056143144572747422538333594694756756655696798979976879958687957995676939686658475475623336500612
662533125413523284737634669357979456995895856799797767679899585888899799675553357648455413641663031
014206153225663545455694774965848955686699676678777689996997596965668976646983688667633463335404141
413012617325174456878669973969459678955956597997687976869576778966464554568469886777721516427616513
502662203642612255238447486939957458967857897679766997696655868558575999589335922456844736112131654
212661502516734223324889447354689969855787756889968698877896757975877697383989627364337421772343024
062105566125733258245733457473775547779958796868868895787767755559647545379345865238624356123242000
402335614754636628236824679555597465548989986755969565969678898559987586856955673832271674166105362
451334645753376162243335579543677879955598768556565759756869877876795947966569855573232735534601241
500262052615557247375888358635954578969966856685689678868986899965887995757987425824514566556143415
025221464647151347477323745438738647477798995699788989796688598687779795846437577837865212462025305
506261641542645445623578634938859695857548567987658895685668887664467397754563764284864222243613255
544001251632514343434242438697698767785468785559797877757559476976744589553445545348132556324315401
312662335054751647576346847944998349986995969646958568675577475645539379875732364426714676752004534
442336642122316123757636234859863735657746598877646757975758669549947438746824526434264347133600103
110222605363451462773826376864836593598856459788567868745977445869448964569655348846536363204056350
000101232124176476234372634789857987399659768658796566947966644948468844584756623732364133065443412
134465433226374477324823357757785535937975665949586889647565456766846389552458234767667646466124353
421406224300535763513347544755878674693949665984559799965894778876384773264625738631365460212615513
452351220036426717772576544574486575445936589965659469684553983864958887588836456352652752044465624
513131310021516677236857346343788436737376979889979498674877368855367664436225742117611411543534241
025341550553445563557374338552585545787433393754685485676457956894674542662544752536711135543323540
535152616216423251726174753447757785566344854848638858756838495369785886445488572266324260520452211
040010242452167571763413223445374499838658479769797468459895353937866635767567612446231533425561512
540233435611063354343623584674548775576735445736954663985773597646587532834332126771664204465150223
115125460640513624264577427672484376565394997956949478368583668555354324253116433334364541633501141
325235035031330065764773672233563447278366899833655673943396323666327273534372213517324021336301134
210455052102126060367721574443448283734742249765698995536842573866568587565571317173455040136014133
130303041444343616551636147765524538863657233824485633222587838375574238775244261440413305250410213
215411311040450233266672334763832288583822422248882386376826865647256855122326112462046245434214110
230231555011111141243461222762213386584878775753548542777758687642766773174237314624160241043301041
323544455001621231632772663352437368846236258422868628887825466644733647626344222306513541033345051
103143140115330535101443674523313247636278477357763543634765673375252223123145511514215131041302240
232425305344242122243634141575125456216884578682284677823883878251534364736772005201664151453532422
102015414143426060302001452111353522415644252842283555326642135161755673127454553246636405351210230
434225550123100466121402111553624464277266354226553673463535217337233242261322143516321221202244233
241043514014314144343662453056766274716234347315115145214653247673432611160552306341450310405413111
242112143335044304622645260260424573275613637141734623226773527441742321265241643455134145215344111
111301110035433343532532505066367716542154757534155161173124736561116131435620565213531350550432142
242323242143224035106205224411500635634124323342513747342475634262646442514656422055112331122023144
002021344233114150010341663531513334522142253265466242366366534525551142525131661102314124401314042
024004104024242151413420354625126365606642452553232242411563750634302214411623615524332515123123121
322320201030004104054100060453523451362415465573527326430616603635233444523531105134335533102202414
013231044323002420215041311645066036204353535300445225661352044506065120312154410321400034312200320
031030413344440552442114452066553136026033443442226333515665300213012326102141034413121232242040400
133131302014414220215344004521556454235620502443013233464014064103264525100404050140223431001414000
221120341111243124154321401255010441026151433422443520262166251632146441120442553301443334201231200
021222222103332103301112520131442023663055232552042262505152050120510455441325453404132240001402111

61
2022/08/main.py Normal file
View File

@@ -0,0 +1,61 @@
from typing import Callable, Iterable
from utils.input import read_input_lines
lines = read_input_lines()
grid = list(map(lambda line: list(map(int, line)), lines))
rows = len(grid)
cols = len(grid[0])
def is_visible(x: int, y: int) -> bool:
if x <= 0 or y <= 0:
return True
if x >= cols - 1 or y >= rows - 1:
return True
height = grid[y][x]
if all(grid[y][x_adj] < height for x_adj in range(0, x)):
return True
if all(grid[y][x_adj] < height for x_adj in range(x + 1, cols)):
return True
if all(grid[y_adj][x] < height for y_adj in range(0, y)):
return True
if all(grid[y_adj][x] < height for y_adj in range(y + 1, rows)):
return True
return False
def count_until_and_including(predicate: Callable, iterable: Iterable) -> int:
count = 0
for item in iterable:
count += 1
if not predicate(item):
break
return count
def calculate_scenic_score(x: int, y: int) -> int:
height = grid[y][x]
visible_l = count_until_and_including(lambda x_adj: grid[y][x_adj] < height, reversed(range(0, x)))
visible_r = count_until_and_including(lambda x_adj: grid[y][x_adj] < height, range(x + 1, cols))
visible_u = count_until_and_including(lambda y_adj: grid[y_adj][x] < height, reversed(range(0, y)))
visible_d = count_until_and_including(lambda y_adj: grid[y_adj][x] < height, range(y + 1, rows))
return visible_l * visible_r * visible_u * visible_d
visible_trees = sum(is_visible(x, y) for y in range(rows) for x in range(cols))
print(f"Visible trees: {visible_trees}")
highest_scenic_score = max(calculate_scenic_score(x, y) for y in range(rows) for x in range(cols))
print(f"Highest scenic score: {highest_scenic_score}")

3
2022/utils/input.py Normal file
View File

@@ -0,0 +1,3 @@
def read_input_lines() -> list[str]:
with open("input.txt") as f:
return [line.rstrip() for line in f.readlines()]

View File

@@ -1,36 +1,64 @@
These are my solutions to [Advent of Code](https://adventofcode.com) puzzles!
This repository is likely going to be an utter mess of programming languages. If you're interested, read below for the list of used languages, and some info to hopefully get them working on your machine.
This repository is likely going to be an utter mess of programming languages. If you're interested, read below for the list of used languages, and instructions to get them working on your machine.
I have included Run Configurations for JetBrains IDEs, so if you use the appropriate IDE or IntelliJ language plugin, you should see each solved day in the Run/Debug Configurations menu.
Years and days are organized in folders. Every day contains a source code file named `main` with the solution, and the input file `input.txt`. Some years also contain a `utils` folder with shared code used in each day (usually to read the input file).
The solutions always look for the input file in the working directory, so make sure the working directory is set to the day's folder.
If you use JetBrains IDEs, you can open each year's folder in the appropriate IDE. I have included a Run Configuration for each solved day, so you should see them in the Run/Debug Configurations menu.
# Languages
## \[2022\] Python
The `2022` folder does not have any special project. You can run the `main.py` file in each day's folder directly using Python 3.11 or newer (older versions may also work, but this is not guaranteed).
You should be able to load the `2022` folder into [PyCharm](https://www.jetbrains.com/pycharm/).
## \[2021\] Kotlin
The repository contains a Gradle project (`2021/build.gradle.kts`) that sets up every day as a source root and a task that can be launched with `gradlew <day>`, for ex. `gradlew 01`.
The `2021` folder contains a Gradle project (`build.gradle.kts`) that sets up every day as a source root and task that can be launched with `gradlew <day>` (for ex. `gradlew 01`).
You should be able to load the Gradle project into [IntelliJ IDEA](https://www.jetbrains.com/idea/).
The source code is in `main.kt`. The run configuration executes the `main()` method in this file.
## \[2020\] Rust
The repository contains a Cargo project (`2020/Cargo.toml`) that sets up every day as a binary target that can be launched with `cargo run --bin <day>`, for ex. `cargo run --bin 01`.
The `2020` folder contains a Cargo project (`Cargo.toml`) that sets up every day as a binary target that can be launched with `cargo run --bin <day>` (for ex. `cargo run --bin 01`).
You should be able to load the Cargo project into [CLion](https://www.jetbrains.com/clion/).
The source code is in `main.rs`. The run configuration executes the `main()` function in this file.
## \[2017\] PostgreSQL
The `2017` folder contains a Docker Compose file (`docker-compose.yml`) that launches a local PostgreSQL instance on `127.0.0.1:2017`, with the username `postgres` and password `aoc2017`. The container has the `2017` folder mounted to `/aoc`, so that PostgreSQL can see the input files.
To start the Docker container, enter the `2017` folder and run `docker compose up -d`. To stop and remove the Docker container and its data, run `docker compose down -v`.
You can execute the script for each day and get its output by running the following command. See [psql](https://www.postgresql.org/docs/current/app-psql.html) for the documentation of arguments and flags passed to the `psql` program.
```
# First, execute procedures.sql to set up procedures for turning input files into tables.
docker exec aoc-2017-postgres psql postgres postgres -f /aoc/utils/procedures.sql
# Substitute <day> for the specific day you want to run.
docker exec aoc-2017-postgres psql postgres postgres -Atqf /aoc/<day>/main.sql
# For example:
docker exec aoc-2017-postgres psql postgres postgres -Atqf /aoc/01/main.sql
```
**Every day's script begins by dropping all tables whose name begins with that day.** Don't execute these scripts on any database you care about.
You should be able to load the `2017` folder into [DataGrip](https://www.jetbrains.com/datagrip/), where you can attach the PostgreSQL data source, execute the scripts, and explore the tables created in the process.
## \[2015\] NASM x64 Assembly
The repository contains a CMake project (`2015/CMakeLists.txt`) in the respective year's folder, which sets up every day as a CMake subproject.
The `2015` folder contains a CMake project (`CMakeLists.txt`), which sets up every day as a CMake subproject.
You should be able to load the CMake project into [CLion](https://www.jetbrains.com/clion/), as long as you have a toolchain named `Visual Studio x64` set to use the `amd64` architecture.
The source code is in `main.c`, which is either in the puzzle's own folder, or in `utils` if no adjustments are needed. By default, `main.c` reads the whole input file into a buffer, and passes it as a parameter to the `entryPoint` function defined in `main.asm` which implements the logic and output of each puzzle.
The entry point is in `utils/main.c`, which reads the whole input file into a buffer and passes it as a parameter to the `entryPoint` function defined in each day's `main.asm`.
Note that everything is targeted for Windows and assembly is not portable, so running on a different OS will most likely require some changes. You will need to:
Note that everything is targeted for Windows and assembly is not portable, so running on a different OS will most likely require some changes. To compile the code on Windows, you will need to:
1. Install [Visual Studio](https://visualstudio.microsoft.com/) with `MSVC x64/x86 Build Tools`
2. Install [NASM](https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D) (the "Executable only" version will suffice, as long as you setup the system `%PATH%` environment variable to include the folder with `nasm.exe`)
@@ -39,13 +67,24 @@ The versions should not matter, but I used Visual Studio 2019 with `MSVC v142 (1
# Solved Days
| Year | Day | Language | / | Year | Day | Language | / | Year | Day | Language |
|-----:|----:|----------|-----|------|-----|----------|-----|------|-----|----------|
| 2015 | 01 | NASM x64 | / | 2020 | 01 | Rust | / | 2021 | 01 | Kotlin |
| 2015 | 02 | NASM x64 | / | 2020 | 02 | Rust | / | 2021 | 02 | Kotlin |
| 2015 | 03 | NASM x64 | / | 2020 | 03 | Rust | / | 2021 | 03 | Kotlin |
| | | | / | 2020 | 04 | Rust | / | 2021 | 04 | Kotlin |
| | | | / | 2020 | 05 | Rust | / | 2021 | 05 | Kotlin |
| | | | / | 2020 | 06 | Rust | / | 2021 | 06 | Kotlin |
| | | | / | 2020 | 07 | Rust | / | 2021 | 07 | Kotlin |
| | | | / | 2020 | 08 | Rust | / | 2021 | 08 | Kotlin |
| Year | Day | Language | / | Year | Day | Language | / | Year | Day | Language |
|-----:|----:|----------|-----|-----:|----:|------------|-----|-----:|----:|----------|
| 2015 | 01 | NASM x64 | / | 2017 | 01 | PostgreSQL | / | 2020 | 01 | Rust |
| 2015 | 02 | NASM x64 | / | 2017 | 02 | PostgreSQL | / | 2020 | 02 | Rust |
| 2015 | 03 | NASM x64 | / | | | | / | 2020 | 03 | Rust |
| | | | / | | | | / | 2020 | 04 | Rust |
| | | | / | | | | / | 2020 | 05 | Rust |
| | | | / | | | | / | 2020 | 06 | Rust |
| | | | / | | | | / | 2020 | 07 | Rust |
| | | | / | | | | / | 2020 | 08 | Rust |
| Year | Day | Language | / | Year | Day | Language |
|-----:|----:|----------|-----|-----:|----:|----------|
| 2021 | 01 | Kotlin | / | 2022 | 01 | Python |
| 2021 | 02 | Kotlin | / | 2022 | 02 | Python |
| 2021 | 03 | Kotlin | / | 2022 | 03 | Python |
| 2021 | 04 | Kotlin | / | 2022 | 04 | Python |
| 2021 | 05 | Kotlin | / | 2022 | 05 | Python |
| 2021 | 06 | Kotlin | / | 2022 | 06 | Python |
| 2021 | 07 | Kotlin | / | 2022 | 07 | Python |
| 2021 | 08 | Kotlin | / | 2022 | 08 | Python |