Skip to content

Instantly share code, notes, and snippets.

@syntacticsugar
Created April 9, 2020 03:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syntacticsugar/7faabe421efd85584359b67b58377577 to your computer and use it in GitHub Desktop.
Save syntacticsugar/7faabe421efd85584359b67b58377577 to your computer and use it in GitHub Desktop.
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