Hey there xterm, I ran your code(I'm assuming that's groovy) and it outputs "14". However, that is not correct. Given the input strings ["bced","abed","abce","aceb","abcd"] you can construct a machine which will uniquely identify one of them with 3 comparisons at most.
Here are the steps to uniquely identify a string from among those 5 strings.
compare the input string to the second letter of "bced"
If it matches:
We can eliminate "abed" "abce" and "abcd". Leaving us with 2 choices: "bced" and "aceb"
One further comparison is needed to distinguish those two, compare first letter of input with
first letter of "bced".
If it matches:
respond "bced"
Otherwise:
respond "aceb"
Total comparisons: 2
If it doesn't match:
We can eliminate "bced" and "aceb" leaving us with "abed" "abce" and "abcd"
We compare the input with the third letter of "abed".
If it matches:
respond "abed". Done, 2 comparisons
If it doesn't match:
We are left with "abce" and "abcd". Compare the last letter of the input with the last letter of "abce".
If it matches:
respond "abce". Done, 3 comparisons
Otherwise:
respond "abcd". Done, 3 comparisons
The answer is thus 3, since that is the number of comparisons an algorithm will need to make if it knows the set of all possible strings ahead of time and can devise a perfect search algorithm(which is how I understood this problem, though I'm open to correction)
PS: If my understanding of the problem is correct, it is quite obvious that the upper bound on the solution is the length of the input strings. Meaning if our input strings are of length 4, as in your example, that is the upper bound. Since you can, with each 1 comparison, eliminate all strings that are not equal at that position.
PPS: Given that observation, if one could devise an efficient solution to the following subproblem: "Is it possible to uniquely identify one of these strings in `n` comparisons?", it would be possible to find the solution via a binary search on the entire solution space which is 0=>length(strings[0])