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/
As most things, how hard is a problem is subjective. It's entirely possible to have a readable solution even in old Java (pre-Java 8, which added streams, functional interfaces and varargs). Using the diamond operator for brevity, but everything else is just old collections APIs:
Edit: minor edit to consider the case of two words of equal/different length