]> git.sommitrealweird.co.uk Git - advent-of-code-2020.git/commitdiff
Add some one liners to other_ways for day5
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 7 Dec 2020 19:27:48 +0000 (19:27 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 7 Dec 2020 19:27:48 +0000 (19:27 +0000)
day5/other_ways.txt [new file with mode: 0644]

diff --git a/day5/other_ways.txt b/day5/other_ways.txt
new file mode 100644 (file)
index 0000000..62ea744
--- /dev/null
@@ -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)) )