Skip to content

Commit

Permalink
day24
Browse files Browse the repository at this point in the history
  • Loading branch information
vslinko committed Dec 25, 2024
1 parent d7b8e4f commit 68bc95c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/day24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ const INITIAL_VALUE_LINE_LENGTH: usize = 7;
const INPUT_X_POS: usize = 5;
const INPUT_Y_POS: usize = X_Y_SIZE * INITIAL_VALUE_LINE_LENGTH + INPUT_X_POS;
const INPUT_GATES_POS: usize = (X_Y_SIZE + X_Y_SIZE) * INITIAL_VALUE_LINE_LENGTH + 1;
const CONTEXT_SIZE: usize = GATES_COUNT + X_Y_SIZE * 2;
const EDGES_COUNT: usize = 266;
const STACK_SIZE: usize = 90;
const X: usize = b'x' as usize;
const Y: usize = b'y' as usize;
const Z: usize = b'z' as usize;
const CONTEXT_SIZE: usize = GATES_COUNT + X_Y_SIZE * 2;

const OP_AND: u8 = b'A';
const OP_OR: u8 = b'O';
const OP_XOR: u8 = b'X';
Expand Down Expand Up @@ -67,7 +68,7 @@ unsafe fn inner1(input: &str) -> usize {
});

let mut gates = FxHashMap::with_capacity_and_hasher(GATES_COUNT, FxBuildHasher::default());
let mut edges = FxHashMap::with_capacity_and_hasher(266, FxBuildHasher::default());
let mut edges = FxHashMap::with_capacity_and_hasher(EDGES_COUNT, FxBuildHasher::default());

let mut i = INPUT_GATES_POS;
(0..GATES_COUNT).for_each(|_| {
Expand Down Expand Up @@ -111,7 +112,7 @@ unsafe fn inner1(input: &str) -> usize {

let mut sorted_wires = Vec::with_capacity(CONTEXT_SIZE);
let mut in_degree = FxHashMap::with_capacity_and_hasher(GATES_COUNT, FxBuildHasher::default());
let mut stack = Vec::with_capacity(90);
let mut stack = Vec::with_capacity(STACK_SIZE);

wires.iter().for_each(|&wire| {
if let Some(wire_edges) = edges.get(&wire) {
Expand Down

0 comments on commit 68bc95c

Please sign in to comment.