add scripts and readme template
This commit is contained in:
parent
9a9f4622f2
commit
ef47dd932b
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
README.md.temp
|
||||
# ignore all without extension
|
||||
*
|
||||
!*.*
|
||||
!*/
|
||||
*.txt
|
||||
|
12
README.md
12
README.md
@ -4,9 +4,9 @@ This is a repository for my solutions for the [advent of code 2023](https://adve
|
||||
<!-- table begin -->
|
||||
| Day | Language | Execuction time | Comment |
|
||||
| --- |:---: | ---: | --- |
|
||||
| [01](01) | Python | 0m0,015s | one-liners |
|
||||
| [02](02) | Rust | 0m0,001s | My very first rust program |
|
||||
| [03](03) | Rust | 0m0,001s | |
|
||||
| [04](04) | Rust | 0m0,001s | |
|
||||
| [05](05) | Rust | 0m0,001s | very efficient |
|
||||
| [06](06) | Rust | 0m0,001s | quadratic formula go *brrrr* |
|
||||
| [01](01) | Python | 0,015 s | one-liners |
|
||||
| [02](02) | Rust | 0,001 s | My very first rust program |
|
||||
| [03](03) | Rust | 0,001 s | |
|
||||
| [04](04) | Rust | 0,001 s | |
|
||||
| [05](05) | Rust | 0,001 s | very efficient |
|
||||
| [06](06) | Rust | 0,001 s | quadratic formula go *brrrr* |
|
||||
|
9
README.md.temp
Normal file
9
README.md.temp
Normal file
@ -0,0 +1,9 @@
|
||||
# [Day X](https://adventofcode.com/2023/day/X)
|
||||
:gift:
|
||||
|
||||
Today's language: **Y**
|
||||
|
||||
```shell
|
||||
|
||||
```
|
||||
<!-- -->
|
39
make_readme.sh
Executable file
39
make_readme.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
table="| Day | Language | Execuction time | Comment |\n"
|
||||
table+="| --- |:---:| ---:| --- |\n"
|
||||
for day in $(seq -f "%02g" 1 25); do
|
||||
[[ ! -d "$day" ]] && continue
|
||||
# echo $day
|
||||
lang=$(grep -E "Today's language: "'\*\*[a-zA-Z0-9_]+\*\*' $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
|
||||
exe=$(find $day -type f -executable)
|
||||
if [[ $(echo $exe | wc -w) != 1 ]]; then
|
||||
echo "Found multiple or no executables for day $day: '$exe'"
|
||||
time=Error
|
||||
else
|
||||
time=$({ time ./$exe; } 2>&1 | tail -3 | head -1 | awk '{print $2}')
|
||||
re='([[:digit:]]+)m([[:digit:]]+),([[:digit:]]+)s'
|
||||
[[ $time =~ $re ]]
|
||||
min=${BASH_REMATCH[1]}
|
||||
sec=${BASH_REMATCH[2]}
|
||||
msec=${BASH_REMATCH[3]}
|
||||
if [[ $min != 0 ]]; then
|
||||
time="$min m $sec,$msec s"
|
||||
else
|
||||
time="$sec,$msec s"
|
||||
fi
|
||||
# elif [[ $sec != 0 ]]; then
|
||||
# time="$sec,$msec s"
|
||||
# else
|
||||
# time="$((msec+0)) ms"
|
||||
# fi
|
||||
fi
|
||||
comment=$(grep -E "<!-- .* -->" $day/README.md | head -1 | sed -r 's/.*<!-- *(.*) *-->.*/\1/')
|
||||
table+="| [$day]($day) | $lang | $time | $comment |\n"
|
||||
|
||||
done
|
||||
# remove table from readme
|
||||
sed -i '/<!-- table begin -->/q' README.md
|
||||
echo -e $table | column -t -s '|' -o '|' >> README.md
|
9
next_day.sh
Executable file
9
next_day.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
maxday=$(ls -d */ | sed -r 's|0*(.*)/|\1|g' | tail -1)
|
||||
echo $maxday
|
||||
nextday=$((maxday + 1))
|
||||
nextday_dir=$(printf "%02d" $nextday)
|
||||
echo $nextday
|
||||
mkdir $nextday_dir
|
||||
sed "s/X/$nextday/g" README.md.temp > $nextday_dir/README.md
|
Loading…
Reference in New Issue
Block a user