|
|
|
@@ -9,7 +9,7 @@ pub fn process_part1(input: &str) -> HashMap<String, u16> {
|
|
|
|
|
instructions.insert(wire.to_string(), expression.to_string());
|
|
|
|
|
}
|
|
|
|
|
for wire in instructions.keys() {
|
|
|
|
|
set_wire(wire.to_owned(), &mut wires, &instructions);
|
|
|
|
|
set_wire(wire.to_string(), &mut wires, &instructions);
|
|
|
|
|
}
|
|
|
|
|
wires
|
|
|
|
|
}
|
|
|
|
@@ -39,7 +39,7 @@ fn set_wire(
|
|
|
|
|
if parts.len() == 2 {
|
|
|
|
|
let value = set_wire(parts[1].clone(), wires, instructions);
|
|
|
|
|
wires.insert(wire, !value);
|
|
|
|
|
return value;
|
|
|
|
|
return !value;
|
|
|
|
|
}
|
|
|
|
|
if parts.len() == 3 {
|
|
|
|
|
let left = match parts[0].parse::<u16>() {
|
|
|
|
@@ -81,7 +81,24 @@ fn set_wire(
|
|
|
|
|
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)]
|
|
|
|
|
mod tests_7 {
|
|
|
|
|