In line 41 I have added : if (wordsFound.contains(word)) continue; Even if I move this line after 38 it still prints the same result. I don't understand why. When I run the program, this is the result:
same - (1, 1) - (3, 4)
same - (1, 1) - (2, 4)
same - (1, 1) - (4, 1)
same - (1, 1) - (2, 0)
home - (5, 3) - (3, 4)
home - (5, 3) - (2, 4)
home - (5, 3) - (4, 1)
home - (5, 3) - (2, 0)

Process finished with exit code 0