how to get all elements of the blocks in prolog? the size can change dynamic in my code, so the blocksize differs, 4x4 = 4 elements, 9x9= 9 elements etc. the blocks are cut into squares, so in 4x4 the horizontal length is round(sqrt(4))= 2 and vertical length of the block is round(sqrt(4)) = 2. and 9x9 ... sqrt(9).. so height and width of the blocks are 3. i need an algorithm to get the elements efficient.
my sudokulists are build up this way:
L=[ [4,3,1,2], [2,1,4,3], [3,4,2,1], [1,2,3,4] ],
so a list, with lists of the rows in sudoku. checking rows and columns is no problem, -> all_different check with rows, transpose the whole List, all_different check with the transposed list.
but because of the dynamic size of the sudoku, i cannot code fix code for the blocks. so anyone any idea? i thought about flatten(L) and working with offsets to get the correct blocks, but it seems pretty hard to do that this way?
please help me!