diff options
Diffstat (limited to '2020')
-rw-r--r-- | 2020/five.nim | 27 | ||||
-rw-r--r-- | 2020/input/five.txt | 805 |
2 files changed, 832 insertions, 0 deletions
diff --git a/2020/five.nim b/2020/five.nim new file mode 100644 index 0000000..ebad294 --- /dev/null +++ b/2020/five.nim @@ -0,0 +1,27 @@ +# Day Five: Binary Boarding +import os, math, std/enumerate + +let input: string = paramStr(1) + +var + min: int = 2^8 + max: int = 0 + flight: seq[int] +for seat in lines(input): + var row, column, id: int = 0 + for i, char in enumerate(seat[0..^4]): + if char == 'B': + row += 2^(7-i) div 2 + for i, char in enumerate(seat[7..^1]): + if char == 'R': + column += 2^(3-i) div 2 + id = row * 8 + column + max = max(max, id) + min = min(min, id) + flight.add(id) + +echo max + +for id in min .. max: + if id notin flight: + echo id diff --git a/2020/input/five.txt b/2020/input/five.txt new file mode 100644 index 0000000..fb33193 --- /dev/null +++ b/2020/input/five.txt @@ -0,0 +1,805 @@ +FFBBFFFLLL +BFBFBFBLLR +BFFBBBBRRR +FBFBFFFLLL +FFFBFBBRRL +FBBFFBBLLR +FBBBFBFRRR +FBFBBFFLLL +FBFBFBFRRR +FFBFFFFLRL +FBFBFBBLRL +FBFFFBBLLR +FBBBBBFLLL +BBFBFFFLLL +FBBBBFBLRL +FBBBBFBRRR +FBFFBBBLLL +FBFFFFFLLR +BFBFFFFRRL +BFFFBBBLRL +FBBBBFBRLL +BFBFBBBRLR +BFBBFFFLRR +BBFFFFBRRR +FFBFBBFRRR +FFBFBFBLRR +BBFBBFBRRL +BBFBFBFLRR +FBBBBFFLRR +BFBFBBBLRL +BFBFFFFRLL +BBFFFBFRLR +BBFFFBBLRR +FBFBBBFRRL +BFBFBBFLRL +BBFFBBBRLL +BBFFBBBLRL +FBFFFFFRLR +FBFBFBFRRL +FBBFBFBLLR +BFBBFFBLLL +BFFFFBFRLR +FBBFFFFLRR +FFFBBFBRRR +FBFFBFFLRR +FFBBFBBLLR +FBFBBFBLLR +BFFBBFBRLR +FFBB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