Add to_s to Board
This commit is contained in:
		
							parent
							
								
									d573aad4f2
								
							
						
					
					
						commit
						c8ee8c311e
					
				
					 4 changed files with 72 additions and 0 deletions
				
			
		
							
								
								
									
										17
									
								
								src/board.cr
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								src/board.cr
									
										
									
									
									
								
							|  | @ -57,6 +57,23 @@ module Sudoku | |||
|         } | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     # Convert a board to its string representation | ||||
|     def to_s | ||||
|       @grid.map { |row| | ||||
|         row.map { |cell| | ||||
|           case cell | ||||
|           when Nil | ||||
|             '.' | ||||
|           else cell.to_s | ||||
|           end | ||||
|         }.join | ||||
|       }.join("\n") | ||||
|     end | ||||
| 
 | ||||
|     def solved? | ||||
|       @grid.flatten.none? { |i| i == nil } | ||||
|     end | ||||
|        | ||||
|   end | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,8 @@ | |||
| module Sudoku | ||||
|   class Solver | ||||
| 
 | ||||
|     def self.solve(board) | ||||
|     end | ||||
| 
 | ||||
|   end | ||||
| end | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue