-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_report.sh
45 lines (39 loc) · 1.13 KB
/
generate_report.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/bash
set -e # Exit on fail
set -u # Exit if using an undefined variable
set -o pipefail # A pipe fails if one of its command fails
shopt -s extglob lastpipe # Persist hashmap values outside of loops
declare -A stars # Declare a hashmap
printf "| Day " ;
for folder in $("ls" -d */)
do
printf "|[${folder%/}](https://adventofcode.com/${folder%/})"
done
echo "|"
printf "| --: " ;
for folder in $("ls" -d */)
do
printf "| :--------: "
stars[$folder]=0
done
echo "|"
for i in $(seq -w 25)
do
printf "| $i "
for folder in $("ls" -d */)
do
printf "|"
compgen -G "$folder$i/first*" >/dev/null && printf ":star": && stars[$folder]=$(( ${stars[$folder]} + 1 ))
compgen -G "$folder$i/second*" > /dev/null && printf ":star:" && stars[$folder]=$(( ${stars[$folder]} + 1 ))
compgen -G "$folder$i/solve*" > /dev/null && printf ":star::star:" && stars[$folder]=$(( ${stars[$folder]} + 2 ))
done
printf "\n"
done
counter=0
printf "| Total"
for folder in $("ls" -d */)
do
printf " | %i" ${stars[$folder]}
counter=$(( counter + ${stars[$folder]} ))
done
printf "\n\nTotal stars: %i\n" $counter