aboutsummaryrefslogtreecommitdiff

Advent of Code 2023

My solutions for Advent of Code 2023. The language used may be anything. I started with sh. I don't know why. The final files have not been cleaned; there is a lot of commented experimentation (especially in the sh files).

https://adventofcode.com/2023

Other people's solutions

Check out! These!
jedevc lavigne958

My solutions

Asides: I am not trying to optimise the length or execution time of my scripts further than "it works in a reasonable amount of time".

Day Solution Chars Runtime
01 - Trebuchet?! bash █░░░░░░░░░ 930 ░░░░░░░░░░░░░░░░░░░░ 0.030 s
02 - Cube Conundrum bash █░░░░░░░░░ 828 ░░░░░░░░░░░░░░░░░░░░ 0.020 s
03 - Gear Ratios bash ██████░░░░ 7,954 ░░░░░░░░░░░░░░░░░░░░ 0.029 s
04 - Scratchcards bash ░░░░░░░░░░ 467 ░░░░░░░░░░░░░░░░░░░░ 0.025 s
05 - If You Give A Seed A Fertilizer bash + python ██████████ 2,029 + 11,005 ████████████████████ 88.934 s
06 - Wait For It bash ░░░░░░░░░░ 474 ███░░░░░░░░░░░░░░░░░ 11.995 s
07 - Camel Cards bash ██░░░░░░░░ 2804 ░░░░░░░░░░░░░░░░░░░░ 0.098 s
08 - Haunted Wasteland bash + python ██░░░░░░░ 2092 + 158 ░░░░░░░░░░░░░░░░░░░░ 0.099 s
09 - Mirage Maintenance bash ██░░░░░░░░ 2300 ░░░░░░░░░░░░░░░░░░░░ 0.168 s
10 - Pipe Maze bash ████░░░░░░ 5052 ░░░░░░░░░░░░░░░░░░░░ 0.240 s
11 - Cosmic Expansion bash ██░░░░░░░░ 2242 ░░░░░░░░░░░░░░░░░░░░ 1.696 s
12 - Hot Springs not solved not solved not solved

To run

Bash solutions

Either cat the data file into the script file with a pipe, or give the filename as input to the script:

cat data/day1.txt | ./scripts/day01_1.sh
# or
./scripts/day01_1.sh data/day1.txt

All solutions at once

Up to n

for i in {01..n}; do echo "day ${i}"; ./scripts/day${i}.sh ./data/day${i}.txt; done

Metrics

Measure execution time

Use time, like so:

$ time ./scripts/day02_01.sh data/day2.txt
real    0m0.021s
user    0m0.016s
sys     0m0.000s

Send execution time to readme

$ ./runtime.sh 06

writing ███░░░░░░░░░░░░░░░░░ (11.995 s) to day 06...

Create bar chart

Arguments (described in file) are PROGRESS, TOTAL, and NUMBER of SEGMENTS.

$ ./bar.sh 7954 13034 10

██████░░░░