add loc
This commit is contained in:
parent
76f54fb6c3
commit
a1eccb5f34
@ -3,6 +3,8 @@
|
||||
|
||||
Today's language: **Python**
|
||||
|
||||
Lines of code: **3**
|
||||
|
||||
Execution time: **0,021 s**
|
||||
|
||||
Both tasks are solved in one hell of a oneliner each:
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
Today's language: **Rust**
|
||||
|
||||
Lines of code: **49**
|
||||
|
||||
Execution time: **0,002 s**
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
Today's language: **Rust**
|
||||
|
||||
Lines of code: **85**
|
||||
|
||||
Execution time: **0,006 s**
|
||||
|
||||
```shell
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
Today's language: **Rust**
|
||||
|
||||
Lines of code: **40**
|
||||
|
||||
Execution time: **0,004 s**
|
||||
|
||||
```shell
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
Today's language: **Rust**
|
||||
|
||||
Lines of code: **138**
|
||||
|
||||
Execution time: **0,009 s**
|
||||
|
||||
Super fast!
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
Today's language: **Rust**
|
||||
|
||||
Lines of code: **60**
|
||||
|
||||
Execution time: **0,001 s**
|
||||
|
||||
*Midnight formula go brrrrr*
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
Today's language: **Rust**
|
||||
|
||||
Lines of code: **210**
|
||||
|
||||
Execution time: **0,007 s**
|
||||
|
||||
Not pretty, but pretty fast.
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
Today's language: **Rust**
|
||||
|
||||
Lines of code: **101**
|
||||
|
||||
Execution time: **0,039 s**
|
||||
|
||||
Next time, I should just use 64 bit right from the start...
|
||||
|
23
README.md
23
README.md
@ -2,13 +2,16 @@
|
||||
This is a repository for my solutions for the [advent of code 2023](https://adventofcode.com/2023).
|
||||
|
||||
<!-- table begin -->
|
||||
| Day | Language | Execuction time | Comment |
|
||||
|:---: |:---: | ---: | --- |
|
||||
| [01](01) | Python | 0,021 s | one-liners |
|
||||
| [02](02) | Rust | 0,002 s | my very first rust program |
|
||||
| [03](03) | Rust | 0,006 s | |
|
||||
| [04](04) | Rust | 0,004 s | |
|
||||
| [05](05) | Rust | 0,009 s | very efficient |
|
||||
| [06](06) | Rust | 0,001 s | quadratic formula go *brrr* |
|
||||
| [07](07) | Rust | 0,007 s | not pretty, but pretty fast |
|
||||
| [08](08) | Rust | 0,039 s | |
|
||||
| Day | Language | Lines of code | Execuction time | Comment |
|
||||
|:---: |:---: | ---: | --- | |
|
||||
| [01](01) | Python | 3 | 0,021 s | one-liners |
|
||||
| [02](02) | Rust | 49 | 0,002 s | my very first rust program |
|
||||
| [03](03) | Rust | 85 | 0,006 s | |
|
||||
| [04](04) | Rust | 40 | 0,004 s | |
|
||||
| [05](05) | Rust | 138 | 0,009 s | very efficient |
|
||||
| [06](06) | Rust | 60 | 0,001 s | quadratic formula go *brrr* |
|
||||
| [07](07) | Rust | 210 | 0,007 s | not pretty, but pretty fast |
|
||||
| [08](08) | Rust | 101 | 0,039 s | |
|
||||
| [09](09) | Rust | 88 | 0,003 s | implemented triangle datatype |
|
||||
|
||||
Lines of code are without blank lines and comments
|
||||
|
@ -15,11 +15,14 @@ function find_lang {
|
||||
# 1: fileext, 2: lang, 3: howto
|
||||
sourcefile=$(ls $day_dir/*.$1 2> /dev/null)
|
||||
[[ $? != 0 ]] && return
|
||||
sourcefile=$(basename $sourcefile)
|
||||
printf "$FMT_VAR" "Determined Langugae" "$2 ($sourcefile)"
|
||||
lang=$2
|
||||
sourcefilebase=$(basename $sourcefile)
|
||||
printf "$FMT_VAR" "Determined Langugae" "$2 ($sourcefilebase)"
|
||||
sed -i "s/LANG/$2/" $readme
|
||||
howto=$(echo "$3" | sed "s|SOURCE|$sourcefile|")
|
||||
howto=$(echo "$3" | sed "s|SOURCE|$sourcefilebase|")
|
||||
sed -i "s(HOWTORUN($howto(" $readme
|
||||
loc=$(sed -r '/^\s*(#|\/\/|\/\*|;)/d;/^\s*$/d' $sourcefile | wc -l)
|
||||
sed -i "s(LOC($loc(" $readme
|
||||
}
|
||||
|
||||
function get_time {
|
||||
@ -28,6 +31,7 @@ function get_time {
|
||||
exe=$(basename $exe)
|
||||
if [[ $(echo $exe | wc -w) != 1 ]]; then
|
||||
printf "$FMT_ERR" "Found multiple or no executables for day $day: '$exe'"
|
||||
cd ..
|
||||
return 1
|
||||
time=Error
|
||||
else
|
||||
@ -37,6 +41,7 @@ function get_time {
|
||||
printf "\e[34m"
|
||||
echo -e "$time"
|
||||
printf "\e[0m"
|
||||
cd ..
|
||||
return 1
|
||||
fi
|
||||
time=$(echo -e "$time" | tail -3 | head -1 | awk '{print $2}')
|
||||
@ -50,6 +55,7 @@ function get_time {
|
||||
else
|
||||
time="$sec,$msec s"
|
||||
fi
|
||||
cd ..
|
||||
# elif [[ $sec != 0 ]]; then
|
||||
# time="$sec,$msec s"
|
||||
# else
|
||||
@ -74,8 +80,6 @@ else
|
||||
sed -i '/.*EXECTIME.*/d' $readme
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
printf "$FMT_WARN" "No comment provided"
|
||||
sed -i "/<!-- COMMENT -->/d" $readme
|
||||
|
@ -1,15 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
table="| Day | Language | Execuction time | Comment |\n"
|
||||
table="| Day | Language | Lines of code | 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:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
|
||||
exectime=$(grep -E "Execution time:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
|
||||
loc=$(grep -E "Lines of code:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
|
||||
comment=$(grep -E "<!-- .* -->" $day/README.md | head -1 | sed -r 's/.*<!-- *(.*) *-->.*/\1/')
|
||||
table+="| [$day]($day) | $lang | $exectime | $comment |\n"
|
||||
table+="| [$day]($day) | $lang | $loc | $exectime | $comment |\n"
|
||||
done
|
||||
# remove table from readme
|
||||
sed -i '/<!-- table begin -->/q' README.md
|
||||
echo -e $table | column -t -s '|' -o '|' >> README.md
|
||||
echo -e "\n Lines of code are without blank lines and comments" >> README.md
|
||||
|
Loading…
Reference in New Issue
Block a user