my problem is: While learning Prolog i wanted to make a NxN Sudoku solver. This solver will get the input like
[[1,2,3,4],[3,4,1,2],[2,3,4,1],[4,1,2,3]]
Where some of them might be variables. The solver has to solve that Sudoku. The problem is way smaller:
firstElementsOf([],_).
firstElementsOf([[X|_]|Rest2],Y) :-
firstElementsOf(Rest2,Y2),
append([X],[Y2],NotFlat),
flatten(NotFlat,Y).
This should be the beginning of checking, if every column has distinct numbers. The Y
from firstElementsOf
should contain only the first elements of the given rows. In the Example:
[1,3,2,4]
Sadly, thanks to append, it always adds another empty space to the Y
list.
It gives:
[1,3,2,4,_1320]
Question1: Is there a way to get rid of that _1320
?
Question2: Is this even right? Will there be a way to get the 2nd and 3rd elements of the Input with that?