From: Mart Lubbers Date: Sat, 5 Dec 2020 15:07:11 +0000 (+0100) Subject: 5 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=096572a98e62f6882f82a94e3d5b41d72f153166;p=aoc20.git 5 --- diff --git a/5/input b/5/input new file mode 100644 index 0000000..34edaca --- /dev/null +++ b/5/input @@ -0,0 +1,869 @@ +FFFFBBBRLR +BFBBFBFRRR +FFBFBBFRRL +BFBFBBFRRR +BFBBFFFLLR +FFFBFFFRRL +BFFBFFFLLL +BFFBFFFRRL +FFBBFBBLRR +BBFBBFBLLL +BFFFFBFRRL +BFFFBFBLLR +BBFFBFFRLR +BFBFBBFLLR +BBFBFBFRLR +BBFFBFFRRL +FBFFFBFLRL +BFFFBBFLLL +FBFFFFFLLR +FBFFFBFLRR +BFBFBFBLLR +BFBBBFFRLR +FBBBFFFLRR +BBBFFFFLRL +FBBFFFFLRR +BFFFBFBRLL +BFBBBBBLLL +BBFBFBFRLL +FFBFBBBRRR +FBBBFBBLRL +BFFBFBFRRR +BBFFBFBRLR +FBFFFFBRRR +FBFBBFBLRR +BBBFFFBLLL +FBFFBBFLLL +FBFBBBBLRL +BFBFBFBLRL +BFBFFBFLLL +FBBBBFFRRR +BFBFFBBRLL +FFBFBBFLRL +BFBBBFFLLR +FBFFBBBLRL +BFBBBFFRRR +FFFBFBBLLR +FFBBFFBRLL +BFFBBFBRLL +BFBBFBBLRR +BFFFFBBRRL +FFFBBFFLLR +FBFBBFFLRL +FFFBFBBRLL +FBBBFBFLRL +BFFFBBBRLL +FFBFBFBLLR +FBFBFFBLRL +FBBFBFBLLL +FFFBBBBLLL +BFFBBBFRRL +BFFFBBBRRL +BBFBBBBRLR +FFBFBBBRRL +FFFBFFFLRR +BFFFBBBLRL +BFBFFBBRRL +BBBFFFBLRL +FFFBFFBLLL +BFBFFBBLLL +BFBBFBBRLR +FFFBFFBLLR +BBFBFFFLRR +BFFFFBFRRR +BBFBBFBLRR +BFFFFFBRRL +FFFFBBBLRR +BBB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FFFBBFBRLL +FBBBBBFLRL +BFBFBBBRRL +FFBFFBBLRL +BBFBBFFRRL +FBFBBBBLLR +BFFFBBBRLR +BBBFFFFRLR +FFBFBBFLRR +BFFFBBBLLR +FBBBBFBLRL +FFFFBBFLRR +FBFBBFBRRR +FBFBBBFRRR +BFFBFFBLLL +FBBBBBBRRL +FFBBFFFRRL +BBFBFFBLLR +FBBFFFFRLR +FBBFFBBRLL +BFBBBBFLLR +BBBFFBFLRL +BBFFBBBRLR +BFBBFBFLRL +FFBBBFBLLR +FFFFBBFRLR +FBBBFBBLRR +BBFBBFFLRL +BBFBBBBRRR +BFFFBFFRRL +BFFBBFFRRR +FFBFBFBRLL +FFBFBBBRLR +FBBFFBFRRL +FBBFFFFLRL +FBBFFBBRRL +BFFBFBFRRL +FFFBFFFLLL +FBFFFFFRLR +BFBBBBFLRL +FFFFBFBRRR +BFFFBBFLRR +BFBBBFBRRL +BBFBBFBRRR +BBFFFBFRLL +BFFBFBBLLL +FBFBFFBRRR +FFBBBBBRRR diff --git a/5/one.icl b/5/one.icl new file mode 100644 index 0000000..8eedf88 --- /dev/null +++ b/5/one.icl @@ -0,0 +1,23 @@ +module one + +import StdEnv + +read :: *File -> [[Int]] +read f + # (l, f) = freadline f + | l.[size l - 1] <> '\n' = [] + = [[tobin c\\c<-:l % (0, size l - 2)]:read f] +where + tobin 'B' = 1 + tobin 'F' = 0 + tobin 'R' = 1 + tobin 'L' = 0 + +Start w + # (io, w) = stdio w + # ls = read io + = (one ls, findHole (sort (map seatNo ls))) + +findHole x = hd [b+1\\a<-x & b<-tl x & c<-tl (tl x) | a+1 == b && b+1 <> c] +one = foldl (\m v->if (v>m) v m) 0 o map seatNo +seatNo = foldl (\n s->s + 2*n) 0