From 193ef004d4c380b8f1edf21c609dd184101fb888 Mon Sep 17 00:00:00 2001 From: "matthias@arch" Date: Sat, 9 Dec 2023 13:46:15 +0100 Subject: [PATCH] update readmes --- 01/README.md | 4 ++++ 02/README.md | 5 +++++ 03/README.md | 6 ++++++ 04/README.md | 8 +++++++- 05/README.md | 6 +++++- 06/README.md | 10 +++++++++- 07/README.md | 13 +++++++++---- 08/README.md | 4 ++++ 09/README.md | 4 ++++ 10/README.md | 4 ++++ 11/README.md | 4 ++++ 12/README.md | 4 ++++ 13/README.md | 8 +++++++- 14/README.md | 4 ++++ 15/README.md | 13 +++++++++++++ README.md | 25 ++++++++++++++++++++++++- 16 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 15/README.md diff --git a/01/README.md b/01/README.md index 5ef1ab7..054dca0 100644 --- a/01/README.md +++ b/01/README.md @@ -3,6 +3,10 @@ Today's language: **awk** + **GNU-coretils** +Lines of code: **2** + +Execution time: **0,0011 s** + - Task 1: We use awk to find the maximum while we iterate through the file - Task 2: We use awk again for summing the calories, then sort them and take the top 3 which we again sum up with awk ```shell diff --git a/02/README.md b/02/README.md index dcb8c34..93c7f38 100644 --- a/02/README.md +++ b/02/README.md @@ -1,7 +1,12 @@ # [Day 2](https://adventofcode.com/2022/day/2) :gift::gift: + Today's language: **C++** +Lines of code: **40** + +Execution time: **0,003 s** + We use that chars are just numbers, so we can easily convert them into the respective points by just subtracting `'A'` or `'X'`. The rest is then just a few `if else`s. ```shell diff --git a/03/README.md b/03/README.md index bde3750..7b0dc8c 100644 --- a/03/README.md +++ b/03/README.md @@ -3,8 +3,14 @@ Today's language: **C** +Lines of code: **78** + +Execution time: **0,001 s** + Extra: Task 1 in **vimscript**, generated by OpenAI with just a few fixes by myself + + All the characters (the Elf's items) occuring in (half) a line (backpack) are stored as bits in an unsigned long, duplicate characters can then be determined by bitwise and-ing these numbers. ```shell # Find the item type that appears in both compartments of each rucksack. What is the sum of the priorities of those item types? diff --git a/04/README.md b/04/README.md index 5e5d816..71d8431 100644 --- a/04/README.md +++ b/04/README.md @@ -1,7 +1,13 @@ # [Day 4](https://adventofcode.com/2022/day/4) :gift::gift::gift::gift: -Today's language: **gnu x86-64** (and alternatively **C**) +Today's language: **x86-64 Assembly** + +Lines of code: **241** + +Execution time: **0,010 s** + + Today I wanted to use ChatGPT to solve the tasks using *gnu* **x86-64 assembly**, which I have never used before (I did some small things in [6502-asssembly](https://github.com/MatthiasQuintern/6502), so it wasn't all new). diff --git a/05/README.md b/05/README.md index 2189389..89c1605 100644 --- a/05/README.md +++ b/05/README.md @@ -1,7 +1,11 @@ # [Day 5](https://adventofcode.com/2022/day/6) :gift::gift::gift::gift::gift: -Today's language: **Snek** (Python) +Today's language: **Python** + +Lines of code: **44** + +Execution time: **0,016 s** ```shell python3 crates.txt diff --git a/06/README.md b/06/README.md index 3e4ee3b..2678a7d 100644 --- a/06/README.md +++ b/06/README.md @@ -1,10 +1,18 @@ # [Day 6](https://adventofcode.com/2022/day/6) :gift::gift::gift::gift::gift::gift: -Today's language: **HTML** *javascript ;)* +Today's language: **Javascript** +and **HTML :o** +Lines of code: **125** + +Execution time: **0,067 s** + + + ```shell firefox day6.html ``` diff --git a/07/README.md b/07/README.md index 64a1fad..33c2f13 100644 --- a/07/README.md +++ b/07/README.md @@ -1,18 +1,22 @@ # [Day 7](https://adventofcode.com/2022/day/7) :gift::gift::gift::gift::gift::gift::gift: -Today's language: **Bash** + **awk** +Today's language: **Bash + Awk** -## Day 7 is stupid +Lines of code: **53** + +Execution time: **0,039 s** + +## The protagonist is stupid The way the challenge is laid out is absolutely ridiculus; both tasks could be done in one-liners on a Linux machine *(which the device from the challenge probably is)* in any POSIX shell, -*if* the user wasn't as stupid... +*if* the user wasn't as stupid as our protagonist... That's why I wrote a bash script that actually creates the whole filesystem from the input-file. It does so (by default) in `/tmp`. The sizes for the files are only allocated, so that `du` shows the filesize. No actual write operations are taking place, which makes recreating the file structure pretty fast. -### I am stupid +### And so am I? The problem is, that (even empty) directories have a size, which also increases with every file and subdirectory in it. That's why I needed to calculate the sizes of the directories *without* the actual file sizes and subtract that from the output of `du`. This new output can then be piped into an `awk` one-liner. In reality, this problem wouldn't exist since you would want the total size of a directory anyway. @@ -29,3 +33,4 @@ du -b / | awk 'BEGIN{file=""; size=99999999} {if ($1 >= min_size && $1 < size) { ```shell ./day7.sh output.txt ``` + diff --git a/08/README.md b/08/README.md index 6873e8c..f192e6b 100644 --- a/08/README.md +++ b/08/README.md @@ -3,6 +3,10 @@ Today's language: **C++** +Lines of code: **116** + +Execution time: **0,002 s** + I hope we are not missing the wood for the trees... ```shell diff --git a/09/README.md b/09/README.md index 9aad0b8..042bc1f 100644 --- a/09/README.md +++ b/09/README.md @@ -3,6 +3,10 @@ Today's language: **php** +Lines of code: **87** + +Execution time: **0,126 s** + My very first php-program :v: ```shell php -S localhost:8000 -t . diff --git a/10/README.md b/10/README.md index 4fd1639..60b480f 100644 --- a/10/README.md +++ b/10/README.md @@ -3,6 +3,10 @@ Today's language: **Java** +Lines of code: **48** + +Execution time: **12,085 s** + ```shell javac Main.java java Main diff --git a/11/README.md b/11/README.md index 2cac3eb..d06431f 100644 --- a/11/README.md +++ b/11/README.md @@ -3,6 +3,10 @@ Today's language: **Python** +Lines of code: **71** + +Execution time: **0,284 s** + ```shell python3 day11.py monkey-stuff.txt ``` diff --git a/12/README.md b/12/README.md index f8ef181..744d618 100644 --- a/12/README.md +++ b/12/README.md @@ -3,6 +3,10 @@ Today's language: **C++** +Lines of code: **142** + +Execution time: **0,670 s** + ```shell g++ -std=c++20 day12.cpp -o day12 ./day12 diff --git a/13/README.md b/13/README.md index 095185e..2f6179a 100644 --- a/13/README.md +++ b/13/README.md @@ -3,6 +3,12 @@ Today's language: **HolyC** -Yes. HolyC. In TempleOS. +Lines of code: **228** + +Execution time: **< 0,500 s** + +Yes. HolyC. On TempleOS. + + ![TempleOS Screenshot](day13.png "It actually runs") diff --git a/14/README.md b/14/README.md index 9aa9f48..38cd886 100644 --- a/14/README.md +++ b/14/README.md @@ -3,6 +3,10 @@ Today's language: **C++** +Lines of code: **113** + +Execution time: **0,085 s** + ```shell g++ -std=c++20 main.cpp -o day14 -lgzutil ./day14 i-dont-like-sand.txt diff --git a/15/README.md b/15/README.md new file mode 100644 index 0000000..42c35cc --- /dev/null +++ b/15/README.md @@ -0,0 +1,13 @@ +# [Day 15](https://adventofcode.com/2022/day/15) +:gift::gift::gift::gift::gift::gift::gift::gift::gift::gift::gift::gift::gift::gift::gift: + +Today's language: **C** + +Lines of code: **98** + +Execution time: **0,801 s** + +```shell +gcc day15.c -o day15 +./day15 beacons.txt +``` diff --git a/README.md b/README.md index fa6c818..ae09ace 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,27 @@ Also, check out the repositories of my friends who do stuff in go, Visual Basic, - **Javascript**: day 6 - **php**: day 9 - **Python**: day 5, 11 -- **VIM-Script**: day 3 +- **VIM-Script**: day 4 + + +| Day | Language | Lines of code | Execuction time | Comment | +|:---: |:---: | ---: | ---: |--- | +| [01](01) | GNU-coretils | 2 | 0,0011 s | | +| [02](02) | C++ | 40 | 0,003 s | | +| [03](03) | C | 78 | 0,001 s | including ChatGPT extra | +| [04](04) | x86-64 Assembly | 241 | 0,010 s | ChatGPT tought me Assembly | +| [05](05) | Python | 44 | 0,016 s | | +| [06](06) | Javascript | 125 | 0,067 s | it's a website! | +| [07](07) | Bash + Awk | 53 | 0,039 s | creates the filesystem | +| [08](08) | C++ | 116 | 0,002 s | | +| [09](09) | php | 87 | 0,126 s | | +| [10](10) | Java | 48 | 12,085 s | | +| [11](11) | Python | 71 | 0,284 s | | +| [12](12) | C++ | 142 | 0,670 s | | +| [13](13) | HolyC | 228 | < 0,500 s | yes, coded in HolyC on TempleOS | +| [14](14) | C++ | 113 | 0,085 s | | +| [15](15) | C | 98 | 0,801 s | | +| [16](16) | | | | | + + Lines of code are without blank lines and comments +