Compare commits

..

No commits in common. "193ef004d4c380b8f1edf21c609dd184101fb888" and "c24f9d6080fefdf53547129dfd7c09e73a42ecf4" have entirely different histories.

17 changed files with 11 additions and 117 deletions

View File

@ -3,10 +3,6 @@
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

View File

@ -1,12 +1,7 @@
# [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

View File

@ -3,14 +3,8 @@
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
<!-- 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.
```shell
# 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,13 +1,7 @@
# [Day 4](https://adventofcode.com/2022/day/4)
:gift::gift::gift::gift:
Today's language: **x86-64 Assembly**
Lines of code: **241**
Execution time: **0,010 s**
<!-- ChatGPT tought me Assembly -->
Today's language: **gnu x86-64** (and alternatively **C**)
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).

View File

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

View File

@ -1,18 +1,10 @@
# [Day 6](https://adventofcode.com/2022/day/6)
:gift::gift::gift::gift::gift::gift:
Today's language: **Javascript**
and **HTML :o**
Today's language: **HTML** *javascript ;)*
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)
-->
<!-- it's a website! -->
```shell
firefox day6.html
```

View File

@ -28,7 +28,6 @@ start.addEventListener("click", () => {
function findPosition(line) {
console.time("day06")
let i = 4;
let packetStart = line.substring(0, 4); // should always contain 4 chars
let messageStart = line.substring(0, 14); // should always contain 14 chars
@ -50,9 +49,8 @@ function findPosition(line) {
messageStart = messageStart.substring(1, 14) + line[i];
}
else {
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";
console.timeEnd("day06")
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";
return;
}
}

View File

@ -1,22 +1,18 @@
# [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**
Lines of code: **53**
Execution time: **0,039 s**
## The protagonist is stupid
## Day 7 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 as our protagonist...
*if* the user wasn't as stupid...
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.
### And so am I?
### I am stupid
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.
@ -33,4 +29,3 @@ du -b / | awk 'BEGIN{file=""; size=99999999} {if ($1 >= min_size && $1 < size) {
```shell
./day7.sh output.txt
```
<!-- creates the filesystem -->

View File

@ -3,10 +3,6 @@
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

View File

@ -3,10 +3,6 @@
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 .

View File

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

View File

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

View File

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

View File

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

View File

@ -3,10 +3,6 @@
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

View File

@ -1,13 +0,0 @@
# [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,27 +29,4 @@ 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 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
- **VIM-Script**: day 3