Get a basic Flake setup

This commit is contained in:
Greg Hellings
2024-10-15 16:54:57 -05:00
commit 7f97b1ed9f
7 changed files with 297 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
#[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);
}
}