Skip to the content

Is it a pangram?

Problem

A pangram is a sentence that uses every letter of the alphabet, from a to z. "Zoe packed six jars of vegan broth, a quiz book and waxy plums for my flight." is one: not a single letter is missing.

Write a function that takes a sentence and returns true if it is a pangram and false if it is not.

The rules: the 26 letters from a to z are the ones that count, and a capital letter is the same letter as its lowercase one. Nothing else is a letter: spaces, digits, punctuation, ñ and accented vowels are not in the way, but they do not help either, so an á does not stand in for an a. With an empty sentence you return false, because there is no letter in it.

Watch out for two shortcuts that are not: a long sentence is not a pangram just for being long, and 26 different characters are not 26 different letters. The only thing that matters is that no letter is missing.

There are two roads, and both work: walk the alphabet asking whether each letter is in the sentence, or walk the sentence collecting the letters that show up and see whether you ended with 26.

Examples

  • Not one letter missing

    "Zoe packed six jars of vegan broth, a quiz book and waxy plums for my flight." → true

  • The v is missing

    "Zoe packed six jars of lentil broth, a quiz book and waxy plums for my flight." → false

  • Just the alphabet

    "abcdefghijklmnopqrstuvwxyz" → true

  • With accents and an enye

    "the naïve señor packed six jars of vegan broth, a quiz book and waxy plums for my café" → true

  • All in capitals

    "ZOE PACKED SIX JARS OF VEGAN BROTH, A QUIZ BOOK AND WAXY PLUMS FOR MY FLIGHT." → true

  • With digits and underscores

    "zoe_packed_6_jars_of_vegan_broth_a_quiz_book_and_waxy_plums_for_my_flight" → true

  • Letters swapped for digits

    "z03 p4ck3d s1x j4rs 0f v3g4n br0th, 4 qu1z b00k 4nd w4xy plums f0r my fl1ght" → false

Besides these, the challenge has hidden tests that are revealed when you submit your solution.

You start with this

Python

def is_pangram(text):
    pass

JavaScript

function isPangram(text) {
}
Solve this challenge

It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.

More O(n) challenges

See all challenges →