Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant). Given a string, detect whether or not it is a pangram. Return True if it is, False if not. Ignore number…
#https://www.codewars.com/kata/545cedaa9943f7fe7b000048/train/ruby
def panagram? str
chars_only = ->(string) {string.split('').map(&:downcase).uniq.select{ |c| c =~ /[[:alpha:]]/ }}
chars_only[str].size.eql? 26
end
def panagram?(string)
('a'..'z').all? { |x| string.downcase.include? (x) }
end
def panagram?(string)
string.downcase.scan(/[a-z]/).uniq.size == 26
end
def panagram?(s)
("A".."Z").to_a - s.upcase.chars == []
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment