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