Conversation
Basic spec file working with no tests.
Add .gitignore and get rid of swap files Add SudokuBoard class and implement access to a single element.
New class reads input file and creates game board; Methods to return a specific element, row, or column.
Expose game board for analysis; test for missing elements (zeros); Set up initial structure for testing validity.
Now need to display error information. Refactored the sub_grid_start computation of row/col.
Modified SudokuValidator methods to return error values and convert to strings for reporting CLI program not printing those results yet have some duplication to be taken care of before that step.
report_errors now a separate method to generate error strings.
Duplication removed from check_<element>_validity methods.
1. Remove unnecessary to_s conversion in valid_element? method 2. Change invalid sudoku result spec to test for include, not eq, so that we can add error descriptions.
Works for invalid/complete sudokus; next is incomplete sudokus.
Ignore missing (zero) elements in board.
|
The bin file is missing but you did a very great work! For your I thinks it's better to give an array with rows and columns instead of You have one test file but the files with code. I thinks it's better to split it. In your executable file, I think you can place a method to build the message in the validator class. You probably should had more spaces in your spec file too. In your spec file, you do You have an empty before block in your tests. You did that At least, I think you can move the |
|
@GCorbel - thank you very much for your comments; much appreciated. I'll respond here to each of your points and then go dig into the code for a bit.
Thanks again for your feedback! |
Remove empty before block Add spacing between describe/it blocks Split specs for SudokuBoard and SudokuValidator into two files.
First part of eliminating Law of Demeter violation (@game.game.board[0][0] constructs). First, reference the SudokuBoard instance as 'board', not 'game'.
Add []= method to SudokuBoard for cleaner access to board array, then use that in the specs for modifying the board for tests. This finishes the cleanup of the old @game.board.board[0][0] code.
lib/sudoku_board.rb
Outdated
There was a problem hiding this comment.
it's a pet peeve, but i don't think these should be left as comments in the file. git history can be used if necessary.
There was a problem hiding this comment.
Agreed, @elubin; I overlooked them and will delete them.
Great challenge! Here's my take on the SudokuValidator. I'm looking forward to feedback. while I continue to work on improving the code.