Created
April 9, 2020 03:37
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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