From 3a7d07f766da08174d208a644ae7139364ea68dd Mon Sep 17 00:00:00 2001 From: Dominique Liberda Date: Fri, 9 Dec 2022 12:24:27 +0100 Subject: [PATCH] day 4, part 1 --- 04/01.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 04/01.sh diff --git a/04/01.sh b/04/01.sh new file mode 100755 index 0000000..5343cfa --- /dev/null +++ b/04/01.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Paula fronting, so we're gonna do things a lil' differently +data="$(cat /tmp/04)" + +count=0 +while read line; do + IFS=, meow=($line) + IFS=- uwu=(${meow[0]}) + IFS=- owo=(${meow[1]}) + unset IFS + + if [[ ${uwu[0]} -gt ${owo[0]} ]]; then + [[ ${owo[1]} -ge ${uwu[1]} ]] && count=$((count+1)) + elif [[ ${uwu[0]} == ${owo[0]} ]]; then + [[ ${owo[1]} -ge ${uwu[1]} || ${uwu[1]} -ge ${owo[1]} ]] && count=$((count+1)) + else + [[ ${uwu[1]} -ge ${owo[1]} ]] && count=$((count+1)) + fi + +done <<< "$data" + +echo $count +