I'm working on a search algorithm project, finding the solution for the 16 puzzle.
I have two lists of structs that contain a 2D array board[N][N]
The numbers in the list are unique in a range of 0-15, the difference is their order.
BoardA = 0 1 2 3 BoardB = 4 1 2 3
4 5 6 7 0 5 6 7
8 9 10 11 8 9 10 11
12 13 14 15 12 13 14 15
As you can see, the only difference between boards will be the order of the numbers. Obviously it is possible to iterate through each board checking if
BoardA[i][j] == BoardB[i][j]
However, if there are hundreds or thousands of boards on a list, comparing them this way is undesirable.
Is there a way to quickly or efficiently compare two boards for sameness?