diff --git a/01/README.md b/01/README.md index 6053f31..289b119 100644 --- a/01/README.md +++ b/01/README.md @@ -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: diff --git a/02/README.md b/02/README.md index fbb30cb..a797557 100644 --- a/02/README.md +++ b/02/README.md @@ -3,6 +3,7 @@ Today's language: **Rust** +Lines of code: **49** Execution time: **0,002 s** diff --git a/03/README.md b/03/README.md index 55ea59b..643bf2d 100644 --- a/03/README.md +++ b/03/README.md @@ -3,6 +3,8 @@ Today's language: **Rust** +Lines of code: **85** + Execution time: **0,006 s** ```shell diff --git a/04/README.md b/04/README.md index 36c59ba..178d8ff 100644 --- a/04/README.md +++ b/04/README.md @@ -3,6 +3,8 @@ Today's language: **Rust** +Lines of code: **40** + Execution time: **0,004 s** ```shell diff --git a/05/README.md b/05/README.md index a93f9c3..4d22019 100644 --- a/05/README.md +++ b/05/README.md @@ -3,6 +3,8 @@ Today's language: **Rust** +Lines of code: **138** + Execution time: **0,009 s** Super fast! diff --git a/06/README.md b/06/README.md index 31284fb..81c20e9 100644 --- a/06/README.md +++ b/06/README.md @@ -3,6 +3,8 @@ Today's language: **Rust** +Lines of code: **60** + Execution time: **0,001 s** *Midnight formula go brrrrr* diff --git a/07/README.md b/07/README.md index a266bed..6e7e877 100644 --- a/07/README.md +++ b/07/README.md @@ -3,6 +3,8 @@ Today's language: **Rust** +Lines of code: **210** + Execution time: **0,007 s** Not pretty, but pretty fast. diff --git a/08/README.md b/08/README.md index d948dae..723c513 100644 --- a/08/README.md +++ b/08/README.md @@ -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... diff --git a/README.md b/README.md index 91625f9..8889096 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,16 @@ This is a repository for my solutions for the [advent of code 2023](https://adventofcode.com/2023). -| 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 diff --git a/make_day_readme.sh b/make_day_readme.sh index 70329ad..33e02e4 100755 --- a/make_day_readme.sh +++ b/make_day_readme.sh @@ -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 "//d" $readme diff --git a/make_readme.sh b/make_readme.sh index 406470e..6f59778 100755 --- a/make_readme.sh +++ b/make_readme.sh @@ -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 '//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