Where we work we are still on Net 2.0, but I'm familiar with 3.0 / 3.5 stuff. I wanted to get some practice to use linq / lambda expression in C #, so I have written a simple sudoku solver, which can be found in the most common list & lt; T & gt;
and uses lambda expressions.
In my solver, it is at the top of the Solver Algorithm:
Personalized puzzle recursive solvice (puzzle p, int idx) {// to start with simple filter To reduce the recursive path, // puzzle is still resolved without this line, but it takes at least 20x long (p.board.Any (cell => cell.FilterPossibles ()) ); // whereas(); & Lt; - While the loop is deliberately
As you might possibly know, this is a simple recursive algorithm, but I have been able to do this for some time (3.6 s
To understand the snippet, puzzle.board
is a list
cell.filterposylables ()
each cell Checks the potential values of values against the values of the other cells in the same row, column and 3x3 box so that it can detect that If it is possible, then it sets the value for the cell and gives it right, otherwise it is wrong, so long as there is at least one cell change on the loop board
I am worried that when the loop is empty it is a code odor and tells me that I am probably missing something There is no way that I make it as a statement Can I write in the form of a vehicle?
As a result of this project I actually have so many questions: (I have unknowingly implemented some interfaces which I can tell about compiler What's in Are my options of function usually suitable? I have Boolean methods to simplify expressions: How can this be improved? How can I use temporary puzzles / cell objects to use it?) But this is it now that I'm stealing the most. A free time loop suggests either bugs or side effects - in this case this side- Looks like the effect, the board is changing.
What would happen "LINQ-" (but it is not necessarily actually capable - it really depends) the machine that created the puzzle - the maker of another New will return the board (side-effect-free).
I'm not really "up", which is what you are doing, so be it e is not fair - but this is my first line of inquiry.
Alternatively, I would probably like to think of writing it in any way that to make it more clear that you do is the side-effect - but then, your Without knowing the code it is difficult to say how it will work.
Comments
Post a Comment