[TASK] Solved Day 15

This commit is contained in:
2020-12-16 09:14:38 +01:00
parent e80edae003
commit b118845a5e
5 changed files with 54 additions and 10 deletions

View File

@@ -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;
}
}