7 row_number=$(row_part=${row//F/0}; row_part=${row_part//B/1}; echo $((2#$row_part)))
8 col_number=$(col_part=${col//L/0}; col_part=${col_part//R/1}; echo $((2#$col_part)))
9 seat_id=$((($row_number*8) + $col_number))
10 echo "$seat_id,$row_number,$col_number"
17 while read -u 3 line; do
18 data=$(parse_line $line)
21 seats[$seat_id]=$row_col
24 sorted_seats=( $(echo "${!seats[@]}" | tr ' ' '\n' | sort -g) )
26 echo Last seat id: ${sorted_seats[$((${#sorted_seats[@]}-1))]}
28 # find our seat by going through the sorted list and finding the first mismatch
29 seat_num=${sorted_seats[0]}
30 for seat in ${sorted_seats[@]}; do
31 if [ $seat -ne $seat_num ]; then
32 echo "Your seat number is: $seat_num"
35 seat_num=$((seat_num+1))