From 65709a002552c4824c18047ead579f68c69c39a1 Mon Sep 17 00:00:00 2001 From: Ummon Date: Sun, 15 Dec 2019 21:27:58 +0100 Subject: [PATCH] Beginning of day 14 --- data/day14.input | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ src/day14.rs | 29 ++++++++++++++++++++++++ src/main.rs | 1 + 3 files changed, 88 insertions(+) create mode 100644 data/day14.input create mode 100644 src/day14.rs diff --git a/data/day14.input b/data/day14.input new file mode 100644 index 0000000..596c7f6 --- /dev/null +++ b/data/day14.input @@ -0,0 +1,58 @@ +3 PTZH, 14 MHDKS, 9 MPBVZ => 4 BDRP +4 VHPGT, 12 JSPDJ, 1 WNSC => 2 XCTCF +174 ORE => 4 JVNH +7 JVNH => 4 BTZH +12 XLNZ, 1 CZLDF => 8 NDHSR +1 VDVQ, 1 PTZH => 7 LXVZ +1 ZDQRT => 5 KJCJL +2 SGDXK, 6 VDVQ, 1 RLFHL => 7 GFNQ +8 JFBD => 5 VDVQ +1 SGDXK => 6 ZNBSR +2 PNZD, 1 JFBD => 7 TVRMW +11 TRXG, 4 CVHR, 1 VKXL, 63 GFNQ, 1 MGNW, 59 PFKHV, 22 KFPT, 3 KFCJC => 1 FUEL +6 BTZH => 8 GTWKH +5 WHVKJ, 1 QMZJX => 6 XLNZ +18 JSPDJ, 11 QMZJX => 5 RWQC +2 WFHXK => 4 JSPDJ +2 GHZW => 3 RLFHL +4 WHVKJ, 2 RWQC, 2 PTZH => 8 WNSC +1 QPJVR => 2 VFXSL +1 NCMQC => 6 GDLFK +199 ORE => 5 PNZD +2 RZND, 1 GTWKH, 2 VFXSL => 1 WHVKJ +1 VDVQ => 8 WFHXK +2 VFXSL => 4 VHMT +21 SBLQ, 4 XLNZ => 6 MGNW +6 SGDXK, 13 VDVQ => 9 NBSMG +1 SLKRN => 5 VKXL +3 ZNBSR, 1 WNSC => 1 TKWH +2 KJCJL => 6 LNRX +3 HPSK, 4 KZQC, 6 BPQBR, 2 MHDKS, 5 VKXL, 13 NDHSR => 9 TRXG +1 TKWH, 36 BDRP => 5 BNQFL +2 BJSWZ => 7 RZND +2 SLKRN, 1 NDHSR, 11 PTZH, 1 HPSK, 1 NCMQC, 1 BNQFL, 10 GFNQ => 2 KFCJC +3 LXVZ, 9 RWQC, 2 KJCJL => 7 VHPGT +2 GTWKH, 1 LNRX, 2 RZND => 1 MHDKS +18 RZND, 2 VHPGT, 7 JSPDJ => 9 NCMQC +2 NBSMG, 3 KJCJL => 9 BPQBR +124 ORE => 1 JFBD +1 QPJVR, 2 QMZJX => 4 SGDXK +4 BPQBR, 1 LNRX => 2 KZQC +1 KJCJL, 15 GTWKH => 2 SBLQ +1 ZDQRT, 3 CZLDF, 10 GDLFK, 1 BDRP, 10 VHMT, 6 XGVF, 1 RLFHL => 7 CVHR +1 KZQC => 8 MPBVZ +27 GRXH, 3 LNRX, 1 BPQBR => 6 XGVF +1 XCTCF => 6 KFPT +7 JFBD => 4 GHZW +19 VHPGT => 2 SLKRN +9 JFBD, 1 TVRMW, 10 BTZH => 6 BJSWZ +6 ZNBSR => 4 PTZH +1 JSPDJ, 2 BHNV, 1 RLFHL => 3 QMZJX +2 RCWX, 1 WNSC => 4 GRXH +2 TKWH, 5 NCMQC, 9 GRXH => 3 HPSK +32 KZQC => 5 RCWX +4 GHZW, 1 TVRMW => 1 QPJVR +2 QPJVR, 8 GHZW => 5 ZDQRT +1 VDVQ, 1 WFHXK => 6 BHNV +1 ZNBSR, 6 TKWH => 8 CZLDF +1 MGNW => 5 PFKHV \ No newline at end of file diff --git a/src/day14.rs b/src/day14.rs new file mode 100644 index 0000000..40a3182 --- /dev/null +++ b/src/day14.rs @@ -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::().unwrap(), + String::from(quantity_and_name[1].trim()) + ) +} + +fn parse(input: &str) -> HashMap)> { + let result = HashMap::)>::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 diff --git a/src/main.rs b/src/main.rs index 1d13545..32decbf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"); -- 2.45.2