From 06cf9467341911cc728691594f25be45f2352ec1 Mon Sep 17 00:00:00 2001
From: ida <ida@is.nota.live>
Date: Fri, 8 Dec 2023 19:56:32 -0700
Subject: [PATCH] comment

---
 day4.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/day4.sh b/day4.sh
index 619e36e..336a338 100755
--- a/day4.sh
+++ b/day4.sh
@@ -2,21 +2,21 @@
 #set -vx
 declare -a game
 while read card; do
-	echo $card
-	c="$(echo "${card%\:*}" | tr -cd [:digit:])"
-	game[$c]=${game[$c]:-0}
+	echo $card # show what's being processed
+	c="$(echo "${card%\:*}" | tr -cd [:digit:])" # grab the game number
+	game[$c]=${game[$c]:-0} # set wins to zero if game isnt initialized
 	while read win; do
 		while read num; do
-			if [[ $num == $win ]] && [[ $num != "" ]];
+			if [[ $num == $win ]] && [[ $num != "" ]]; # check if number matches a winning number
 			then
-				(( game[$c]++ ))
+				(( game[$c]++ )) # increment win count for game
 			fi
-		done < <( echo -n "${card#*\:}" | cut -d '|' -f 2 | tr ' ' '\n' | sed '/^$/d' )
+		done < <( echo -n "${card#*\:}" | cut -d '|' -f 2 | tr ' ' '\n' | sed '/^$/d' ) # seperate scractcher numbers (delimiting by newline)
 
-	done < <( echo -n "${card#*\:}" | cut -d '|' -f 1 | tr ' ' '\n' | sed '/^$/d' )
+	done < <( echo -n "${card#*\:}" | cut -d '|' -f 1 | tr ' ' '\n' | sed '/^$/d' ) # seperate winning numbers
 
-done< <( cat $1 )
+done< <( cat $1 ) # file input
 
 for wins in ${game[@]}; do
-	echo $(( 2**($wins-1) ))
+	echo $(( 2**($wins-1) )) # calculate score for all games
 done | tr '\n' '+' | sed 's/+$/\n/' | bc