Python Algorithm for finding hidden matches

52 views Asked by At

I am trying to write a python program to solve a Sudoku board using human standard algorithms (i.e. no entirely bruteforced solution) and have been having trouble with finding an algorithm to manage hidden doubles, triples, and quads. For the sake of this question I am representing the board with a list of lists of lists, with a 2d list representing the Sudoku board, and each square represented as a list of possible values,

i.e.

[[[1,2,3],[4],[5]],
 [[2,6],[8,9],[7]],
 [[6,9],[1,2],[6,8]]]

So an example of a hidden pair in a row would be that for this row

[[1,3,7,8],[1,3,7,8],[2],[4],[3,5,7,9],[1,3,5,8,9],[6],[1,3],[1,8]]

The 5 and 9 at index 4 and 5 would be a hidden pair and after running the function would output this

[[1,3,7,8],[1,3,7,8],[2],[4],[5,9],[5,9],[6],[1,3],[1,8]]

What way would be the best to go about this?

While I've been able to implement working functions for pairs without other values the addition of other values has me stumped. I have heard that hashmaps could be useful for this sort of problem, but I don't have any experience with that. Any help would be greatly appreciated.

0

There are 0 answers