Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Dec 10, 2024
1 parent fa2e8f2 commit b588b57
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/day04/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ impl<'a> Grid<'a> {
}

fn height(&self) -> usize {
self.string.len() / (self.width + 1)
self.string.len() / (self.width() + 1)
}

fn get(&self, x: isize, y: isize) -> Option<&str> {
let i: usize = y.try_into().ok()?;
let j: usize = x.try_into().ok()?;
if j >= self.width {
if j >= self.width() {
return None;
}
let k = i * (self.width + 1) + j;
let k = i * (self.width() + 1) + j;
self.string.get(k..k + 1)
}

Expand Down
6 changes: 3 additions & 3 deletions src/day06/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> Grid<'a> {
}

fn height(&self) -> usize {
self.string.len() / (self.width + 1)
self.string.len() / (self.width() + 1)
}

fn start(&self) -> (isize, isize) {
Expand All @@ -34,10 +34,10 @@ impl<'a> Grid<'a> {
fn get(&self, x: isize, y: isize) -> Option<&str> {
let i: usize = y.try_into().ok()?;
let j: usize = x.try_into().ok()?;
if j >= self.width {
if j >= self.width() {
return None;
}
let k = i * (self.width + 1) + j;
let k = i * (self.width() + 1) + j;
self.string.get(k..k + 1)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/day08/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ impl<'a> Grid<'a> {
}

fn height(&self) -> usize {
self.string.len() / (self.width + 1)
self.string.len() / (self.width() + 1)
}

fn get(&self, x: isize, y: isize) -> Option<&str> {
let i: usize = y.try_into().ok()?;
let j: usize = x.try_into().ok()?;
if j >= self.width {
if j >= self.width() {
return None;
}
let k = i * (self.width + 1) + j;
let k = i * (self.width() + 1) + j;
self.string.get(k..k + 1)
}
}
Expand Down

0 comments on commit b588b57

Please sign in to comment.