Compare commits

...

2 Commits

Author SHA1 Message Date
193ef004d4 update readmes 2023-12-09 13:46:15 +01:00
35512acca9 add time tracking 2023-12-09 13:11:52 +01:00
17 changed files with 117 additions and 11 deletions

View File

@ -3,6 +3,10 @@
Today's language: **awk** + **GNU-coretils** 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 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 - 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 ```shell

View File

@ -1,7 +1,12 @@
# [Day 2](https://adventofcode.com/2022/day/2) # [Day 2](https://adventofcode.com/2022/day/2)
:gift::gift: :gift::gift:
Today's language: **C++** 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'`. 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. The rest is then just a few `if else`s.
```shell ```shell

View File

@ -3,8 +3,14 @@
Today's language: **C** 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 Extra: Task 1 in **vimscript**, generated by OpenAI with just a few fixes by myself
<!-- including ChatGPT extra -->
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. 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 ```shell
# Find the item type that appears in both compartments of each rucksack. What is the sum of the priorities of those item types? # Find the item type that appears in both compartments of each rucksack. What is the sum of the priorities of those item types?

View File

@ -1,7 +1,13 @@
# [Day 4](https://adventofcode.com/2022/day/4) # [Day 4](https://adventofcode.com/2022/day/4)
:gift::gift::gift::gift: :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**
<!-- ChatGPT tought me Assembly -->
Today I wanted to use ChatGPT to solve the tasks using *gnu* **x86-64 assembly**, which I have never used before 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). (I did some small things in [6502-asssembly](https://github.com/MatthiasQuintern/6502), so it wasn't all new).

View File

@ -1,7 +1,11 @@
# [Day 5](https://adventofcode.com/2022/day/6) # [Day 5](https://adventofcode.com/2022/day/6)
:gift::gift::gift::gift::gift: :gift::gift::gift::gift::gift:
Today's language: **Snek** (Python) Today's language: **Python**
Lines of code: **44**
Execution time: **0,016 s**
```shell ```shell
python3 crates.txt python3 crates.txt

View File

@ -1,10 +1,18 @@
# [Day 6](https://adventofcode.com/2022/day/6) # [Day 6](https://adventofcode.com/2022/day/6)
:gift::gift::gift::gift::gift::gift: :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**
<!--
### [Click here to see the website and try it out for yourself](https://quintern.xyz/advent22/day6.html) ### [Click here to see the website and try it out for yourself](https://quintern.xyz/advent22/day6.html)
-->
<!-- it's a website! -->
```shell ```shell
firefox day6.html firefox day6.html
``` ```

View File

@ -28,6 +28,7 @@ start.addEventListener("click", () => {
function findPosition(line) { function findPosition(line) {
console.time("day06")
let i = 4; let i = 4;
let packetStart = line.substring(0, 4); // should always contain 4 chars let packetStart = line.substring(0, 4); // should always contain 4 chars
let messageStart = line.substring(0, 14); // should always contain 14 chars let messageStart = line.substring(0, 14); // should always contain 14 chars
@ -51,6 +52,7 @@ function findPosition(line) {
else { else {
output.innerHTML = "Found the first packet start marker at position <b>" + packetStartI + "</b>, the marker is " + packetStart + "<br>" + output.innerHTML = "Found the first packet start marker at position <b>" + packetStartI + "</b>, the marker is " + packetStart + "<br>" +
"Found the first message start marker at position <b>" + i + "</b>, the marker is " + messageStart + "\n"; "Found the first message start marker at position <b>" + i + "</b>, the marker is " + messageStart + "\n";
console.timeEnd("day06")
return; return;
} }
} }

View File

@ -1,18 +1,22 @@
# [Day 7](https://adventofcode.com/2022/day/7) # [Day 7](https://adventofcode.com/2022/day/7)
:gift::gift::gift::gift::gift::gift::gift: :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)* 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, 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. 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. 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. 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. 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`. 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. 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 ```shell
./day7.sh output.txt ./day7.sh output.txt
``` ```
<!-- creates the filesystem -->

View File

@ -3,6 +3,10 @@
Today's language: **C++** Today's language: **C++**
Lines of code: **116**
Execution time: **0,002 s**
I hope we are not missing the wood for the trees... I hope we are not missing the wood for the trees...
```shell ```shell

View File

@ -3,6 +3,10 @@
Today's language: **php** Today's language: **php**
Lines of code: **87**
Execution time: **0,126 s**
My very first php-program :v: My very first php-program :v:
```shell ```shell
php -S localhost:8000 -t . php -S localhost:8000 -t .

View File

@ -3,6 +3,10 @@
Today's language: **Java** Today's language: **Java**
Lines of code: **48**
Execution time: **12,085 s**
```shell ```shell
javac Main.java javac Main.java
java Main java Main

View File

@ -3,6 +3,10 @@
Today's language: **Python** Today's language: **Python**
Lines of code: **71**
Execution time: **0,284 s**
```shell ```shell
python3 day11.py monkey-stuff.txt python3 day11.py monkey-stuff.txt
``` ```

View File

@ -3,6 +3,10 @@
Today's language: **C++** Today's language: **C++**
Lines of code: **142**
Execution time: **0,670 s**
```shell ```shell
g++ -std=c++20 day12.cpp -o day12 g++ -std=c++20 day12.cpp -o day12
./day12 ./day12

View File

@ -3,6 +3,12 @@
Today's language: **HolyC** Today's language: **HolyC**
Yes. HolyC. In TempleOS. Lines of code: **228**
Execution time: **< 0,500 s**
Yes. HolyC. On TempleOS.
<!-- yes, coded in HolyC on TempleOS -->
![TempleOS Screenshot](day13.png "It actually runs") ![TempleOS Screenshot](day13.png "It actually runs")

View File

@ -3,6 +3,10 @@
Today's language: **C++** Today's language: **C++**
Lines of code: **113**
Execution time: **0,085 s**
```shell ```shell
g++ -std=c++20 main.cpp -o day14 -lgzutil g++ -std=c++20 main.cpp -o day14 -lgzutil
./day14 i-dont-like-sand.txt ./day14 i-dont-like-sand.txt

13
15/README.md Normal file
View File

@ -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
```

View File

@ -29,4 +29,27 @@ Also, check out the repositories of my friends who do stuff in go, Visual Basic,
- **Javascript**: day 6 - **Javascript**: day 6
- **php**: day 9 - **php**: day 9
- **Python**: day 5, 11 - **Python**: day 5, 11
- **VIM-Script**: day 3 - **VIM-Script**: day 4
<!-- table begin -->
| 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