This commit is contained in:
2025-01-28 15:05:32 -05:00
parent 565f638b1b
commit 9f6be9b669
8 changed files with 317 additions and 29 deletions

View File

@@ -1,5 +1,7 @@
use std::{iter::Rev, ops::RangeInclusive};
use num::CheckedSub;
pub fn split_from<T>(min: T, max: T, x: T) -> Vec<Vec<T>>
where
T: num::Integer + Copy,
@@ -22,6 +24,26 @@ where
output
}
pub fn offsets(i: usize, j: usize, range: usize) -> Vec<(usize, usize)> {
let mut output = Vec::new();
for i_o in [-(range as i16), 0, range as i16] {
let new_i = i as i16 + i_o;
if 0 > new_i {
continue;
}
for j_o in [-(range as i16), 0, range as i16] {
let new_j = j as i16 + j_o;
if 0 > new_j {
continue;
}
output.push((new_i as usize, new_j as usize));
}
}
output
}
#[cfg(test)]
mod test {
use super::*;