You could go with something like:
s.downcase.scan(/[a-z]/).uniq.size == 26
This downcases the String scans for all characters "a" through "z" and checks that the uniq size of these characters equals 26.
Issues with your Current solutions
The first one will never work as is
chars
returns an Array
and Array#downcase
is not a method
- You are checking that each letter in the original string occurs 26 times (
string.count(c)==26
) so 'a' * 26
will pass this test but "The quick brown fox jumps over the lazy dog" will not.
The second has issues too:
- the first line serves no purpose. It downcases the string and disposes of the result
String#count
is going to be inefficient;
''
will pass this test as each letter occurs 0 times. e.g. <= 1
times.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…