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