DEV Community

Discussion on: Advent Of Code 2020 in SQL – Day 5: “Binary Boarding”

Collapse
 
saxus profile image
saxus

Hi! I think this solution is way overcomplicated. You can simply cast it into bit(10) then an integer.

Here is my solution:

select
max(translate(rec, 'FLBR', '0011')::bit(10)::integer)
from day5;

Also you don't need to care about the rows and columns in part 1 because it is a single bit array.

Collapse
 
pesse profile image
Samuel Nitsche

I see you're using Postgres' CAST syntax.
Would be neat if this was possible in Oracle - which is not the case (as I wrote in the post).
I agree on the thing that I could just use the whole bit array, but I wanted to implement it as relatable to the original puzzle test as possible.

Collapse
 
saxus profile image
saxus

Oh, I didn't realize, that you're using Oracle.