Base scaffold

This commit is contained in:
Greg Hellings
2024-10-15 19:57:26 -05:00
parent 7f97b1ed9f
commit c31d638dc0
5 changed files with 213 additions and 85 deletions
+8 -9
View File
@@ -1,4 +1,4 @@
#[derive(Clone,Debug,Copy)]
#[derive(Clone, Debug, Copy)]
pub enum CellValue {
One,
Two,
@@ -8,20 +8,19 @@ pub enum CellValue {
Six,
Seven,
Eight,
Nine
Nine,
}
pub struct Cell {
value: Option<CellValue>,
candidates: Vec<CellValue>,
}
impl Default for Cell {
fn default() -> Cell {
Cell {
value : None,
candidates : vec![
value: None,
candidates: vec![
CellValue::One,
CellValue::Two,
CellValue::Three,
@@ -30,19 +29,19 @@ impl Default for Cell {
CellValue::Six,
CellValue::Seven,
CellValue::Eight,
CellValue::Nine
]
CellValue::Nine,
],
}
}
}
#[derive(Default)]
pub struct Board {
cells: [ [ Cell ; 9 ] ; 9 ]
cells: [[Cell; 9]; 9],
}
impl Board {
fn value(self, x: usize, y : usize) -> Option<CellValue> {
fn value(self, x: usize, y: usize) -> Option<CellValue> {
self.cells[x][y].value
}
}