Anyone planning on solving Advent of Code 2020?

Day 5 was fun indeed :slight_smile:
What was the “exploit” you mentioned?

I converted the code to a bitstring which can be converted to a number directly:

calc_seatid(SeatCode)->
    Bits = lists:map(fun(X) -> get_bit(X) end, SeatCode),
    list_to_integer(Bits, 2).

get_bit($F) -> $0;
get_bit($B) -> $1;
get_bit($L) -> $0;
get_bit($R) -> $1.

Full code:

/e: I noticed that I did one unnecessary step and updated my solution

2 Likes