Odd One Out
Write a function that takes a list of words (Strings). The function should return true if exactly 1 word differs in length from the others. It should return false in all other cases.
Examples
(odd-one? ["a" "b" "c"]) ;=> false
(odd-one? ["a" "b" "cc"]) ;=> true
(odd-one? ["abc" "aa" "xyz" "jj"]) ;=> false
Thanks to this site for the problem idea, where it is rated Very Hard in Java. The problem has been modified.
Please submit your solutions as comments on this gist.
To subscribe: https://purelyfunctional.tv/newsletter/
You're right. I've made an error there. This should fix it:
seems to be right, but it's not minimal:
In the latter case we know the result is
False
already after inspecting the third element in the list, so the minimal code would have stopped at that point, without any further work.