--- /dev/null
+#!/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<input.txt
+
+declare -A seats
+
+while read -u 3 line; do
+ data=$(parse_line $line)
+ seat_id=${data%%,*}
+ row_col=${data#*,}
+ seats[$seat_id]=$row_col
+done
+
+sorted_seats=( $(echo "${!seats[@]}" | tr ' ' '\n' | sort -g) )
+
+echo Last seat id: ${sorted_seats[$((${#sorted_seats[@]}-1))]}
+
+# find our seat by going through the sorted list and finding the first mismatch
+seat_num=${sorted_seats[0]}
+for seat in ${sorted_seats[@]}; do
+ if [ $seat -ne $seat_num ]; then
+ echo "Your seat number is: $seat_num"
+ break
+ fi
+ seat_num=$((seat_num+1))
+done
+
+exit 0
+