From 81c3c626144d724b6415ca432ea7989cad9a4057 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net>
Date: Sat, 5 Dec 2020 21:11:41 +0000
Subject: [PATCH] Complete day 5.2

---
 day-5/src/main.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/day-5/src/main.rs b/day-5/src/main.rs
index 62208ce..81f9d27 100644
--- a/day-5/src/main.rs
+++ b/day-5/src/main.rs
@@ -17,6 +17,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
 
     println!("{}", max_id?);
 
+    // Part 2
+    let mut ids = input
+        .lines()
+        .map(|code| {
+            let (row, col) = find_seat(parse_seatcode(code)?);
+            Ok(row * 8 + col)
+        })
+        .collect::<Result<Vec<usize>, String>>()?;
+    ids.sort();
+
+    let mut previous = ids[0];
+    for id in &ids[1..] {
+        if id - 1 != previous {
+            println!("{}", id);
+            break;
+        } else {
+            previous = *id;
+        }
+    }
+
     Ok(())
 }