@tster said:
Sorry, but you've missed the point of the exercise on a few levels. The idea isn't for the potential hire to develop a character searching algorithm. It's for them to display thatComplete the following function:
List<int> findAllOccurences(char[ text, char[ token) { }
a) they can understand a reasonably defined question. ( It's a better defined question that you'll ever get in your carreer as a developer. You're either a pedant or not good enough if you have issues with it - neither of which are desirable attributes)
b) they have a rudimentary knowledge of how .net works (ie, a string can be represented as a char array)
c) they can write a simple application, which works. ( the style of which gives a reasonably good indication of their coding ability.)
With your version, you've essentially given them the answer, and also have given them the ability to do the brain dead easy
string textToSearch = new string(text)
string subtext = new string(token)
allowing them to use textToSearch.IndexOf(subtext) - which takes away the point of the exercise.
The real wtf is that this article actually generated more conversation than "oh my god, what an idiot"