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; }