From 2a21e615b075710bcedf65b334a3811b170080c6 Mon Sep 17 00:00:00 2001 From: Brett Parker Date: Sat, 5 Dec 2020 16:56:23 +0000 Subject: [PATCH 1/1] Bash version of day5 --- day5/get_seat_id.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 day5/get_seat_id.sh 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