[Word-Search]: Tests do not cover all cases

Hi all,
I believe we should change the tests for exercise Word-Search. The current tests do not cover the cases where the same word can be found at multiple places. In such cases, I believe the correct behaviour is to return all found instances, not only the first instance. It’s also more interesting this way.

For example,

let grid = [“clojureclo”; “clojureclo”; “clojureclo”] and wordsToSearchFor = ["clojure”]
the function search should return all:
["clojure",Some((1,1),(7,1)); "clojure",Some((1,2),(7,2)); "clojure",Some((1,3),(7,3))]

To allow that, we need to remove the conversion to Map and use List.sort instead.

I understand the change will break old code.

In my experience, word searches only have a single instance of each word being searched for. It’d be confusing to be asked to look for multiple instances.

1 Like

I agree with that

The issue with first found instance is that there is no single correct answer, and that would render tests ineffective. It depends on where you started first, and in a matrix, there is no obvious way to say this should be looked at first.

Adding more tests/complexity to exercises isn’t always a good thing. The purpose of the exercises isn’t to solve the hardest and most complex version of the program. Sometimes simplifying the problem by constraining the input is a good thing.

Surely the is a correct answer if the word-search has been designed correctly to only have one instance of each word in?