Receipt Bank Logo + Balkan Ruby Logo

Pangram detector

Pangram detector

Goshko is a cute little kid still in kindergarten who has an older sister that is always keen to play a prank on him. Goshko still hasn’t learned to lock his computer when stepping away from it so one day, while he was playing with his equally cute little curly poodle, his sister found his computer unlocked and got to work. She decided that it was time for Goshko to learn the English alphabet, so she wrote a program that wouldn’t let him watch his favourite TV show “My Little Pony” unless he could answer correctly ten times in a row if a given sentence contains all of the alphabet’s letters.

Alas, little Gohsko is still struggling with the alphabet and he just cannot pass the test on his own. He doesn’t even know that such sentences are called pangrams, and he really wants to see the pony’s next adventures! Help him by writing a program that he could use to determine if a given sentence is a pangram. It should count both uppercase and lowercase letters, and ignore any white spaces and punctuation that his devious sister may have thrown in.

Examples:

pangram? 'The quick brown fox jumps over the lazy dog.'     # => true
pangram? 'Did the quick brown fox jump over the lazy dog?'  # => false

Leader board

The lower the score - the better. It is the shortest solution that wins.

If you're ranked in the first 10, stop by our booth to claim your reward.
Winner!

Rank: 1
Nickname: Sve&Evgeny
Score: 43

def pangram? s
(?a..?z).all? { |l| s =~ /#{l}/i }
end
Winner!

Rank: 1
Nickname: pesho
Score: 43

def pangram? s
  (?a..?z)
    .all? { |x| s[/#{x}/i] }
end
Winner!

Rank: 1
Nickname: ignisf
Score: 43

def pangram? s
  (?a..?z).all? { |c| s =~ /#{c}/i }
end
Winner!

Rank: 1
Nickname: Gosho337
Score: 43

def pangram? x
  [*?A..?Z]-x.upcase.chars==[]
end
Winner!

Rank: 1
Nickname: ssk
Score: 43

def pangram? s
  [*?A..?Z] - s.upcase.chars == []
end
Winner!

Rank: 1
Nickname: akseniyap
Score: 43

def pangram? s                                                                       
  (?a..?z).all? { |l| s =~ /#{l}/i }                                           
end
Winner!

Rank: 7
Nickname: tomaz
Score: 47

def pangram? s
  (?A..?Z).to_a - s.upcase.chars == []
end
Winner!

Rank: 7
Nickname: dejaner
Score: 47

def pangram? s
  (?A..?Z).to_a - s.upcase.chars == []
end
Winner!

Rank: 7
Nickname: 🤖
Score: 47

def pangram?(s)
  ('a'..'z').all?{|c|s=~/#{c}/i}
end
Winner!

Rank: 7
Nickname: Cindro
Score: 47

def pangram? s
  (?A..?Y).to_a - s.upcase.chars == []
end

Rank: 11
Nickname: buhtum
Score: 48

def pangram? s
  s.upcase.scan(/\w/).uniq.size==26
end

Rank: 11
Nickname: mimimum
Score: 48

def pangram?(s)
 ('A'..'Z').all? { |c| s.upcase[c] }
end

Rank: 13
Nickname: rb-bikezilla
Score: 49

def pangram? i
!((?A..?Z).to_a-i.upcase.chars)[0]
end

Rank: 14
Nickname: Urby
Score: 51

def pangram? s
  (?A..?Y).to_a - s.upcase.split('') == []
end

Rank: 15
Nickname: hv
Score: 53

def pangram?(s)
  ('a'..'z').to_a - s.downcase.chars == []
end

Rank: 15
Nickname: Dejan Erjavec
Score: 53

def pangram? s
  ('A'..'Z').all? { |i| s.upcase.include? i }
end

Rank: 15
Nickname: lenart
Score: 53

def pangram? s
  ('A'..'Z').all? { |l| s.upcase.include? l }
end

Rank: 18
Nickname: rudel
Score: 55

def pangram?(s)
  ('A'..'Z').all? { |l| s.upcase.include? l }
end

Rank: 18
Nickname: Tim
Score: 55

def pangram?(s)
  (?a..?z).all?{|w| s.downcase.include? w }
end

Rank: 20
Nickname: mediafinger
Score: 56

def pangram?(s)
  s.downcase.scan(/[A-z]/).uniq.count == 26
end

Rank: 21
Nickname: Hiroyuki
Score: 57

def pangram? s
  s.chars.map(&:downcase).sort.uniq[-26]==?a
end

Rank: 21
Nickname: goshko
Score: 57

def pangram? w
  w.upcase.tr('^A-Z', '').chars.uniq.size == 26
end

Rank: 23
Nickname: GeorgeSG
Score: 63

def pangram?(s)
  (('a'..'z').to_a - s.downcase.chars.to_a).empty?
end

Rank: 24
Nickname: foobar
Score: 65

def pangram? s
  foo s
end

def foo s
  (?A..?Z).all? { |l| s.upcase.include? l }
end

Rank: 25
Nickname: mrbph
Score: 82

def pangram?(sentence)
  ("a".."z").to_a == sentence.downcase.scan(/[a-z]/).uniq.sort
end

Rank: 26
Nickname: johndoe
Score: 88

def pangram?(sentence)
  s=sentence
  !(65..90).map {|m| s.upcase.include? m.chr}.include? false
end

Rank: 27
Nickname: nooby
Score: 89

def pangram?(s)
  (s.downcase.split('') & 'abcdefghijklmnopqrstuvwxyz'.split('')).length == 26
end

Rank: 28
Nickname: dsbonev
Score: 103

def pangram?(sentence)
  (('a'..'z').to_a & sentence.tr('^A-Za-z', '').chars.map(&:downcase).uniq).size == 26
end