|
@@ -40,6 +40,10 @@ struct Sudoku {
|
|
|
board: [u8; MAX_SIZE as usize],
|
|
|
}
|
|
|
|
|
|
+const fn pos(x: u8, y: u8) -> u8 {
|
|
|
+ x + (y * SIZE as u8)
|
|
|
+}
|
|
|
+
|
|
|
impl Sudoku {
|
|
|
fn new() -> Self {
|
|
|
let s = Sudoku {
|
|
@@ -56,11 +60,11 @@ impl Sudoku {
|
|
|
|
|
|
fn load_xsudoku(&mut self, s: &str) {
|
|
|
self.clear();
|
|
|
- let mut x :u8= 0;
|
|
|
- let mut y :u8= 0;
|
|
|
+ let mut x: u8 = 0;
|
|
|
+ let mut y: u8 = 0;
|
|
|
for ch in s.chars() {
|
|
|
if ch >= 'b' {
|
|
|
- self.board[pos(x,y) as usize] = ch as u8 - 'a' as u8;
|
|
|
+ self.board[pos(x, y) as usize] = ch as u8 - 'a' as u8;
|
|
|
};
|
|
|
y += 1;
|
|
|
if y >= SIZE {
|
|
@@ -87,10 +91,10 @@ impl Sudoku {
|
|
|
}
|
|
|
println!("");
|
|
|
if y % 3 == 2 {
|
|
|
- if (y+1 == SIZE) {
|
|
|
+ if (y + 1 == SIZE) {
|
|
|
println!("╚═══╩═══╩═══╝");
|
|
|
} else {
|
|
|
- println!("╠═══╬═══╬═══╣");
|
|
|
+ println!("╠═══╬═══╬═══╣");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -158,10 +162,6 @@ const CELLS: [OnlyOne; 3] = [
|
|
|
},
|
|
|
];
|
|
|
|
|
|
-const fn pos(x: u8, y: u8) -> u8 {
|
|
|
- x + (y * SIZE as u8)
|
|
|
-}
|
|
|
-
|
|
|
const POS1: OnlyOne = OnlyOne {
|
|
|
positions: [0, 1, 2, 3, 4, 5, 6, 7, 8],
|
|
|
};
|