Avatar of 4d47

4d47's solution

to Pangram in the Erlang Track

Published at Jul 22 2018 · 0 comments
Test suite


This exercise has changed since this solution was written.

Determine if a sentence is a pangram. 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.

Running tests

In order to run the tests, issue the following command from the exercise directory:

For running the tests provided, rebar3 is used as it is the official build and dependency management tool for erlang now. Please refer to the tracks installation instructions on how to do that.

In order to run the tests, you can issue the following command from the exercise directory.

$ rebar3 eunit

Test versioning

Each problem defines a macro TEST_VERSION in the test file and verifies that the solution defines and exports a function test_version returning that same value.

To make tests pass, add the following to your solution:


test_version() ->

The benefit of this is that reviewers can see against which test version an iteration was written if, for example, a previously posted solution does not solve the current problem or passes current tests.


For detailed information about the Erlang track, please refer to the help page on the Exercism site. This covers the basic information on setting up the development environment expected by the exercises.


Wikipedia https://en.wikipedia.org/wiki/Pangram

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.




% test cases adapted from `x-common//canonical-data.json` @ version: 1.3.0

empty_sentence_test() ->

perfect_lower_case_pangram_test() ->

pangram_with_only_lower_case_test() ->
    ?assert(pangram:is_pangram("the quick brown fox jumps over the lazy dog")).

missing_character_x_test() ->
    ?assertNot(pangram:is_pangram("a quick movement of the enemy will jeopardize five gunboats")).

missing_character_h_test() ->
    ?assertNot(pangram:is_pangram("five boxing wizards jump quickly at it")).

pangram_with_underscores_test() ->

pangram_with_numbers_test() ->
    ?assert(pangram:is_pangram("the 1 quick brown fox jumps over the 2 lazy dogs")).

missing_letters_replaced_by_numbers_test() ->
    ?assertNot(pangram:is_pangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")).

pangram_with_mixed_case_and_punctuation_test() ->
    ?assert(pangram:is_pangram("\"Five quacking Zephyrs jolt my wax bed.\"")).

upper_and_lower_case_characters_are_not_counted_separately_test() ->
    ?assertNot(pangram:is_pangram("the quick brown fox jumps over with lazy FX")).
-export([is_pangram/1, test_version/0]).

test_version() ->

is_pangram(Sentence) ->
    Alphabet = sets:from_list(lists:seq($a, $z)),
    sets:is_subset(Alphabet, sets:from_list(string:casefold(Sentence))).

Community comments

Find this solution interesting? Ask the author a question to learn more.

What can you learn from this solution?

A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.

Here are some questions to help you reflect on this solution and learn the most from it.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?