From 2afcd5263da32ccec315ec35b64a72b6ed0cbfd5 Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Sat, 10 Dec 2022 16:45:28 +0100 Subject: [PATCH] 2022 rust matrix --- 2022/rust/src/solutions/day10.rs | 2 +- 2022/rust/src/utils/matrix.rs | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/2022/rust/src/solutions/day10.rs b/2022/rust/src/solutions/day10.rs index 45cf759..9c19582 100644 --- a/2022/rust/src/solutions/day10.rs +++ b/2022/rust/src/solutions/day10.rs @@ -98,7 +98,7 @@ fn solve2(data: &[Instruction]) -> String { let row = (cycle - 1) / 40; let col = (cycle - 1) % 40; if register - 1 == col || register == col || register + 1 == col { - crt.set_at(row as usize, col as usize, '#'); + crt[(row as usize, col as usize)] = '#'; } } diff --git a/2022/rust/src/utils/matrix.rs b/2022/rust/src/utils/matrix.rs index 0271fa0..6fcbeb3 100644 --- a/2022/rust/src/utils/matrix.rs +++ b/2022/rust/src/utils/matrix.rs @@ -49,21 +49,6 @@ impl Matrix { self.array.iter() } - pub fn get_at(&self, row: usize, col: usize) -> &T { - let offset = self.get_offset(row, col); - &self.array[offset] - } - - pub fn get_mut_at(&mut self, row: usize, col: usize) -> &mut T { - let offset = self.get_offset(row, col); - &mut self.array[offset] - } - - pub fn set_at(&mut self, row: usize, col: usize, value: T) { - let offset = self.get_offset(row, col); - self.array[offset] = value; - } - pub fn cell_indices(&self) -> impl Iterator + '_ { (0..self.rows).into_iter() .flat_map(|row| (0..self.cols).into_iter().map(move |col| (row, col)))