#!/bin/sh day5() { PVAL="0" while read -r VAL; do [ $((PVAL+2 == VAL)) -eq 1 ] && PART2=$((PVAL+1)) PVAL="$VAL" done printf "Part 1: %s\nPart 2: %s\n" "$PVAL" "$PART2" } tr "BFRL" "1010" | awk '{ print "ibase=2;"$1 }' | bc | uniq | sort -n | day5