[TASK] Solved Day 15
This commit is contained in:
15
src/day14.rs
15
src/day14.rs
@@ -31,12 +31,13 @@ fn solve_part1(lines: &Vec<String>) -> u64 {
|
||||
|
||||
fn solve_part2(lines: &Vec<String>) -> u64 {
|
||||
|
||||
/// Idea for performance optimalization: use a Vec containing the "root" memory position, and
|
||||
/// the mask of the floats used to write to that position.
|
||||
/// Whenever something is written, check (using bit operations) if a collision between existing
|
||||
/// memory positions is possible. If that is the case, modify the old (existing) entry by
|
||||
/// removing all overlapping entries in the float mask.
|
||||
///
|
||||
/*
|
||||
Idea for performance optimalization: use a Vec containing the "root" memory position, and
|
||||
the mask of the floats used to write to that position.
|
||||
Whenever something is written, check (using bit operations) if a collision between existing
|
||||
memory positions is possible. If that is the case, modify the old (existing) entry by
|
||||
removing all overlapping entries in the float mask.
|
||||
*/
|
||||
|
||||
let mut mem: HashMap<u64, u64> = HashMap::new();
|
||||
let mut mask = MemoryBitMask { ones_mask: 0, float_masks: Vec::new() };
|
||||
@@ -85,9 +86,7 @@ impl BitMask {
|
||||
|
||||
|
||||
fn apply(&self, x: u64) -> u64 {
|
||||
|
||||
return (x & self.zeros_mask) | self.ones_mask;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user