Basic knowledge of self and regions

This commit is contained in:
Greg Hellings
2024-10-15 22:45:44 -05:00
parent c31d638dc0
commit 6ec40c15f4
6 changed files with 268 additions and 62 deletions
+2 -62
View File
@@ -1,62 +1,2 @@
#[derive(Clone, Debug, Copy)]
pub enum CellValue {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
}
pub struct Cell {
value: Option<CellValue>,
candidates: Vec<CellValue>,
}
impl Default for Cell {
fn default() -> Cell {
Cell {
value: None,
candidates: vec![
CellValue::One,
CellValue::Two,
CellValue::Three,
CellValue::Four,
CellValue::Five,
CellValue::Six,
CellValue::Seven,
CellValue::Eight,
CellValue::Nine,
],
}
}
}
#[derive(Default)]
pub struct Board {
cells: [[Cell; 9]; 9],
}
impl Board {
fn value(self, x: usize, y: usize) -> Option<CellValue> {
self.cells[x][y].value
}
}
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
pub mod cell;
pub mod board;