Skip to content

Instantly share code, notes, and snippets.

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…
def panagram? str
chars_only = ->(string) {string.split('').map(&:downcase){ |c| c =~ /[[:alpha:]]/ }}
chars_only[str].size.eql? 26
def panagram?(string)
('a'..'z').all? { |x| string.downcase.include? (x) }
def panagram?(string)
string.downcase.scan(/[a-z]/).uniq.size == 26
def panagram?(s)
("A".."Z").to_a - s.upcase.chars == []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment