day5: solve part 1 & 2

This commit is contained in:
Johannes Loher 2020-12-08 07:26:29 +01:00
parent 8c2798e26b
commit e99eae4c1f
4 changed files with 1728 additions and 0 deletions

839
day5/part1/input Normal file
View file

@ -0,0 +1,839 @@
BFFBFBFLRL
BFBFBBBLRR
BFBFBFBLRR
BFBFFFFRLR
BBFFBBFRRR
FBBBFFFRLL
FFBFBFFLLL
BBFBFFFRLL
FBBBFFBLRR
FFFFBFFRRL
BFBFBFBRLL
FFBFFBBLLL
BFFBBFFRLR
FBBFFFFLRR
FBFBFFBRRR
FFBFFBBRRR
FBBBFFFRRL
FFBBBBFRRL
BFFBBBBLLL
BFBBFBBLLR
FBBFBFFLLR
FBBFBFFLRR
BFFFFBFLLL
FBBBBBBRRR
FBFFBBFLLR
BBFBFFBRLR
FFFFFBBLLR
FBBFBBBRLL
FFFFBBFRRR
FFFFBFBLRL
FFFBFBFLLR
FFBFBBBLRR
BFFBBBFRLR
FFFBFBBLLL
FBFBBBFLRR
BBFFFBFLLL
FFFFFBBLRR
FFBFBFFRLL
BFFFBBFRLR
BFBBBFBLLR
FFFBBFFLRL
BFBBBFBLLL
FBFBBFBRLR
BBFFBFFRRR
BFFFFBBLRR
FBBBBBFLRL
FBFBBBBRRR
FBFBBFFLLL
BFBBBFBRLL
FFBBFBBLRR
FFBFBBBRRR
FFFFFBFLRL
BFFBBBFLRR
BFBBFBFLLR
FFBFBBBLRL
FBBBBFBLLL
BFBBBFFLRR
FBBFFBBLRR
BFFBBFBLRR
FBBBBBFLLL
FFFFBBBRLR
FBFBBBFLLR
BFBFFBFRLR
BFFBFFBRRR
FBBFFFFLRL
BFBFBBFLRL
BBFBFFFRLR
FBFFFFBLRR
BFFFBFFRLL
FBFFBFBLLR
FFFBFFFRLR
FFFBFFFRLL
BFFBFBBLLL
FFBBFBBLRL
BFBBBBFLRL
BFBBBBFLRR
BFBFFFFRRL
BFBBBFBRLR
BBFFBBBLLR
FBBFBBFRLR
FBFBFBFLLR
BFBFFBBRRR
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RR
BBFBFFFLLR
FBBFBFFRLL
FFBBFBBRLL
FBBBFBFRLL
BFBBFBBRRL
BFBFFFFRLL
BFFFBBBLRR
FFBBBBBLRR
BBFFFBBRLR
BFFBBBFRRL
BBFFBFBLRL
BFFBBBBRRL

24
day5/part1/main.d Normal file
View file

@ -0,0 +1,24 @@
import std;
void main()
{
File("input", "r").byLine.findHighestSeatID.writeln;
}
auto calculateSeatID(const char[] seat)
{
return seat.retro.enumerate.map!(it => "BR".canFind(it.value) ? 2 ^^ it.index : 0).sum;
}
unittest
{
assert("FBFBBFFRLR".calculateSeatID == 357);
assert("BFFFBBFRRR".calculateSeatID == 567);
assert("FFFBBBFRRR".calculateSeatID == 119);
assert("BBFFBBFRLL".calculateSeatID == 820);
}
auto findHighestSeatID(R)(R seats)
{
return seats.map!(seat => seat.calculateSeatID).maxElement;
}

839
day5/part2/input Normal file
View file

@ -0,0 +1,839 @@
BFFBFBFLRL
BFBFBBBLRR
BFBFBFBLRR
BFBFFFFRLR
BBFFBBFRRR
FBBBFFFRLL
FFBFBFFLLL
BBFBFFFRLL
FBBBFFBLRR
FFFFBFFRRL
BFBFBFBRLL
FFBFFBBLLL
BFFBBFFRLR
FBBFFFFLRR
FBFBFFBRRR
FFBFFBBRRR
FBBBFFFRRL
FFBBBBFRRL
BFFBBBBLLL
BFBBFBBLLR
FBBFBFFLLR
FBBFBFFLRR
BFFFFBFLLL
FBBBBBBRRR
FBFFBBFLLR
BBFBFFBRLR
FFFFFBBLLR
FBBFBBBRLL
FFFFBBFRRR
FFFFBFBLRL
FFFBFBFLLR
FFBFBBBLRR
BFFBBBFRLR
FFFBFBBLLL
FBFBBBFLRR
BBFFFBFLLL
FFFFFBBLRR
FFBFBFFRLL
BFFFBBFRLR
BFBBBFBLLR
FFFBBFFLRL
BFBBBFBLLL
FBFBBFBRLR
BBFFBFFRRR
BFFFFBBLRR
FBBBBBFLRL
FBFBBBBRRR
FBFBBFFLLL
BFBBBFBRLL
FFBBFBBLRR
FFB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FBFFBFBRRR
BFFFBBFRLL
BFFFFBBLRL
FFFBBBFRRL
FBFFFBFRRR
FFBBBFFRLL
BFBFFBBLLL
BFBFBBBRRL
BFFFFBFLRL
FBBFBBBRRR
FBBFBBFLRL
FBBBFBBLRR
FBBBFFBRRR
BBFFBFBLRR
FFBBBFFLLR
BFBFBFFLLL
FFBBFFBLLR
FBFBBFFRLL
FBBFFBFLRL
FFBFBFBLRR
FFFBBFBLLR
FFBBFFBLRL
BFBBBBBRRR
BFBFBBFRLL
FFBBFFFLLR
FFBBFFBRLL
FFFBBBFRLR
BFFFBFFLRR
BFFBFBBRLR
BBFFBBBLLL
FBFBFFBLLR
FFFBBFFRRR
BBFBFFFLLR
FBBFBFFRLL
FFBBFBBRLL
FBBBFBFRLL
BFBBFBBRRL
BFBFFFFRLL
BFFFBBBLRR
FFBBBBBLRR
BBFFFBBRLR
BFFBBBFRRL
BBFFBFBLRL
BFFBBBBRRL

26
day5/part2/main.d Normal file
View file

@ -0,0 +1,26 @@
import std;
void main()
{
File("input", "r").byLine.findMissingSeatID.writeln;
}
auto calculateSeatID(const char[] seat)
{
return seat.retro.enumerate.map!(it => "BR".canFind(it.value) ? 2 ^^ it.index : 0).sum;
}
unittest
{
assert("FBFBBFFRLR".calculateSeatID == 357);
assert("BFFFBBFRRR".calculateSeatID == 567);
assert("FFFBBBFRRR".calculateSeatID == 119);
assert("BBFFBBFRLL".calculateSeatID == 820);
}
auto findMissingSeatID(T)(T seats)
{
auto sortedSeatIDs = seats.map!calculateSeatID.array.sort;
return sortedSeatIDs.zip(sortedSeatIDs.drop(1))
.find!(seatPair => seatPair[1] - seatPair[0] != 1).front[0] + 1;
}