For this data structure exercise:
Write a method that returns a boolean indicating whether a string has repeating letters. Capital letters count as repeats of lowercase ones, e.g., repeating_letters?(“Aa”) => true
My interpretation of “repeating letters” after reading that was two letters IN ORDER. Therefore “ALL” has repeating letters (two L’s next to each other), but “LAL” does NOT. I wrote code for that interpretation and it passed all specs (the tests were just “Aa” and “abcd”)
When I looked at the suggested solution:
str.downcase.chars.uniq.length != str.length
I noticed that this was testing for a completely different interpretation where “LAL” would also be considered to have repeating letters because there are two L’s.
It would make more sense, if either the problem description or examples given would clarify which meaning of “repeating letters” is wanted. Thanks!