y2015d6p2
This commit is contained in:
parent
25be019d72
commit
04ae9d47ef
@ -16,5 +16,5 @@ fn part1() {
|
|||||||
fn part2() {
|
fn part2() {
|
||||||
let root = env!("CARGO_MANIFEST_DIR");
|
let root = env!("CARGO_MANIFEST_DIR");
|
||||||
let content = fs::read_to_string(format!("{root}/resources/7_input.txt")).unwrap();
|
let content = fs::read_to_string(format!("{root}/resources/7_input.txt")).unwrap();
|
||||||
println!("{:#?}", d7::process_part2(&content));
|
println!("{}", d7::process_part2(&content).get("a").unwrap());
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,24 @@ fn set_wire(
|
|||||||
panic!("Should not happen");
|
panic!("Should not happen");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_part2(_input: &str) {}
|
pub fn process_part2(input: &str) -> HashMap<String, u16> {
|
||||||
|
let mut wires = HashMap::new();
|
||||||
|
let mut instructions = HashMap::new();
|
||||||
|
for instruction in input.lines() {
|
||||||
|
let (expression, wire) = instruction.split_once(" -> ").unwrap();
|
||||||
|
instructions.insert(wire.to_string(), expression.to_string());
|
||||||
|
}
|
||||||
|
for wire in instructions.keys() {
|
||||||
|
set_wire(wire.to_string(), &mut wires, &instructions);
|
||||||
|
}
|
||||||
|
let new_b = wires.get("a").unwrap();
|
||||||
|
instructions.insert("b".to_string(), new_b.to_string());
|
||||||
|
let mut wires = HashMap::new();
|
||||||
|
for wire in instructions.keys() {
|
||||||
|
set_wire(wire.to_string(), &mut wires, &instructions);
|
||||||
|
}
|
||||||
|
wires
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests_7 {
|
mod tests_7 {
|
||||||
|
Loading…
Reference in New Issue
Block a user