Skip to content

Pangram

Intro

A pangram (Greek: παν γράμμα, pan gramma, "every letter") is a sentence using every letter of the alphabet at least once. The best known English pangram is:

The quick brown fox jumps over the lazy dog.

The alphabet used consists of ASCII letters a to z, inclusive, and is case insensitive. Input will not contain non-ASCII symbols.

Task

Determine if a sentence is a pangram.

The Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include "pangram.h"
#include <algorithm>
#include <cctype>
#include <string>
#include "algorithm"


namespace pangram {
bool is_pangram(std::string test)
{
    std::transform(test.begin(),test.end(),test.begin(),[](unsigned char c){return std::tolower(c);});
    for(char i='a'; i<='z'; i++)
    {
        if(!test.find(i))
            break;
    }
    return false;
}
}  // namespace pangram
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#if !defined(PANGRAM_H)
#define PANGRAM_H

#include "string"

namespace pangram {
    bool is_pangram(std::string);
}  // namespace pangram

#endif // PANGRAM_H

Last update: February 10, 2021

Comments