public static int Part1() { //InputData = "FBFBBFFRLR"; //FindSeat(InputData); foreach (var item in InputData.Split(Environment.NewLine)) { FindSeat(item); } return(Seats.SelectMany(x => x.Seats.Where(y => y.Taken)).Select(x => x.SeatID).Max()); }
public static int Part2() { //InputData = "FBFBBFFRLR"; //FindSeat(InputData); foreach (var item in InputData.Split(Environment.NewLine)) { FindSeat(item); } var possibleSeats = Seats.SelectMany(x => x.Seats.Where(y => !y.Taken)).Select(x => x.SeatID); var takenSeats = Seats.SelectMany(x => x.Seats.Where(y => y.Taken)).Select(x => x.SeatID); return(possibleSeats.First(x => takenSeats.Contains(x - 1) && takenSeats.Contains(x + 1))); }