diff --git a/src/bin/sol_cli.rs b/src/bin/sol_cli.rs index f85972b..8c2dbd4 100644 --- a/src/bin/sol_cli.rs +++ b/src/bin/sol_cli.rs @@ -49,13 +49,13 @@ fn solve_puzzle(board: Board) { println!("No solutions found"); return; } - println!("Found {} solutions", solutions.len()); let solution = solutions.first().unwrap(); let mut idx = 0; solution.iter().for_each(|m| { idx += 1; println!("{}. {}", idx, m.notation()); }); + println!("There are atleast {} solutions to this puzzle", solutions.len()); } fn generate_puzzle(num_pieces: Option, num_solutions: Option) -> Option { diff --git a/src/board.rs b/src/board.rs index bfbaa0f..1492c16 100644 --- a/src/board.rs +++ b/src/board.rs @@ -50,6 +50,7 @@ impl Board { } pub fn from_id(board_id: &str) -> Result { + // TODO: validate board_id before decode let mut board_id_bytes = [0; 8]; board_id_bytes.copy_from_slice(board_id.as_bytes()); let mut working_bytes_slice = [0; 6]; @@ -83,12 +84,12 @@ impl Board { for f in 0..BOARD_SIZE { let c = chars.next().unwrap(); let piece = match c { - 'K' => Piece::King, - 'Q' => Piece::Queen, - 'B' => Piece::Bishop, - 'N' => Piece::Knight, - 'R' => Piece::Rook, - 'P' => Piece::Pawn, + 'K' | 'k' => Piece::King, + 'Q' | 'q' => Piece::Queen, + 'B' | 'b' => Piece::Bishop, + 'N' | 'n' => Piece::Knight, + 'R' | 'r' => Piece::Rook, + 'P' | 'p' => Piece::Pawn, '.' => continue, _ => return Err(SError::InvalidBoard), };