From: Brett Parker Date: Sat, 5 Dec 2020 16:56:23 +0000 (+0000) Subject: Bash version of day5 X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2020.git/commitdiff_plain/2a21e615b075710bcedf65b334a3811b170080c6 Bash version of day5 --- diff --git a/day5/get_seat_id.sh b/day5/get_seat_id.sh new file mode 100644 index 0000000..971394a --- /dev/null +++ b/day5/get_seat_id.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +parse_line() { + line=$1 + row=${line:0:7} + col=${line:7} + row_number=$(row_part=${row//F/0}; row_part=${row_part//B/1}; echo $((2#$row_part))) + col_number=$(col_part=${col//L/0}; col_part=${col_part//R/1}; echo $((2#$col_part))) + seat_id=$((($row_number*8) + $col_number)) + echo "$seat_id,$row_number,$col_number" +} + +exec 3