From: Brett Parker Date: Mon, 7 Dec 2020 19:27:48 +0000 (+0000) Subject: Add some one liners to other_ways for day5 X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2020.git/commitdiff_plain/a2ce7bb47964e226d4b10b791a038ca1f1fa67d7?ds=sidebyside Add some one liners to other_ways for day5 --- diff --git a/day5/other_ways.txt b/day5/other_ways.txt new file mode 100644 index 0000000..62ea744 --- /dev/null +++ b/day5/other_ways.txt @@ -0,0 +1,3 @@ +Getting last seat id: cat input.txt | sed -e 's#[FL]#0#g; s#[BR]#1#g;' | sort | tail -n 1 | (read x; echo $((2#$x))) + +Getting my seat id: cat input.txt | sed 's|[FL]|0|g; s|[BR]|1|g' | sort | sed -ne '1 { x; }; 2,$ { H; x; s#\n#-#g; /10-/ { s#^.*-##; /00$/ {p; q} }; /01-/ { s#^.*-##; /11$/ {p; q; } }; /11-/ { s#^.*-##; /01$/ {p; q; } }; s#^.*-##; x; }' | ( read x; echo $((2#$x - 1)) )