Beginning of day 14
authorUmmon <greg.burri@gmail.com>
Sun, 15 Dec 2019 20:27:58 +0000 (21:27 +0100)
committerUmmon <greg.burri@gmail.com>
Sun, 15 Dec 2019 20:27:58 +0000 (21:27 +0100)
src/day14.rs [new file with mode: 0644]
src/main.rs

diff --git a/src/day14.rs b/src/day14.rs
new file mode 100644 (file)
index 0000000..40a3182
--- /dev/null
@@ -0,0 +1,29 @@
+use std::collections::HashMap;
+
+fn parse_quantity_and_name(input: &str) -> (i32, String) {
+    let quantity_and_name: Vec<&str> = input.split(" ").collect();
+    (
+        quantity_and_name[0].parse::<i32>().unwrap(),
+        String::from(quantity_and_name[1].trim())
+    )
+}
+
+fn parse(input: &str) -> HashMap<String, (i32, Vec<(i32, String)>)> {
+    let result = HashMap::<String, (i32, Vec<(i32, String)>)>::new();
+    for line in input.lines() {
+        let reaction: Vec<&str> = line.split("=>").collect();
+        let input_chemicals: Vec<(i32, String)> =
+            reaction[0].split(",").map(parse_quantity_and_name).collect();
+    }
+    result
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn part1() {
+
+    }
+}
\ No newline at end of file
index 1d13545..32decbf 100644 (file)
@@ -14,6 +14,7 @@ mod day10;
 mod day11;
 mod day12;
 mod day13;
+mod day14;
 
 fn day01() -> String {
     let masses = common::read_list_of_numbers("data/day01.input", "\n");