2024-10-15 19:57:26 -05:00
|
|
|
#[derive(Clone, Debug, Copy)]
|
2024-10-15 16:52:24 -05:00
|
|
|
pub enum CellValue {
|
|
|
|
|
One,
|
|
|
|
|
Two,
|
|
|
|
|
Three,
|
|
|
|
|
Four,
|
|
|
|
|
Five,
|
|
|
|
|
Six,
|
|
|
|
|
Seven,
|
|
|
|
|
Eight,
|
2024-10-15 19:57:26 -05:00
|
|
|
Nine,
|
2024-10-15 16:52:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct Cell {
|
|
|
|
|
value: Option<CellValue>,
|
|
|
|
|
candidates: Vec<CellValue>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for Cell {
|
|
|
|
|
fn default() -> Cell {
|
|
|
|
|
Cell {
|
2024-10-15 19:57:26 -05:00
|
|
|
value: None,
|
|
|
|
|
candidates: vec![
|
2024-10-15 16:52:24 -05:00
|
|
|
CellValue::One,
|
|
|
|
|
CellValue::Two,
|
|
|
|
|
CellValue::Three,
|
|
|
|
|
CellValue::Four,
|
|
|
|
|
CellValue::Five,
|
|
|
|
|
CellValue::Six,
|
|
|
|
|
CellValue::Seven,
|
|
|
|
|
CellValue::Eight,
|
2024-10-15 19:57:26 -05:00
|
|
|
CellValue::Nine,
|
|
|
|
|
],
|
2024-10-15 16:52:24 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub struct Board {
|
2024-10-15 19:57:26 -05:00
|
|
|
cells: [[Cell; 9]; 9],
|
2024-10-15 16:52:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Board {
|
2024-10-15 19:57:26 -05:00
|
|
|
fn value(self, x: usize, y: usize) -> Option<CellValue> {
|
2024-10-15 16:52:24 -05:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|