Exercism v3 launches on Sept 1st 2021. Learn more! 🚀🚀🚀
Avatar of bieniusa

bieniusa's solution

to Pangram in the Erlang Track

Published at Apr 27 2021 · 0 comments
Instructions
Test suite
Solution

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

Questions?

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.

Source

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.

pangram_tests.erl

%% Generated with 'testgen v0.2.0'
%% Revision 1 of the exercises generator was used
%% https://github.com/exercism/problem-specifications/raw/42dd0cea20498fd544b152c4e2c0a419bb7e266a/exercises/pangram/canonical-data.json
%% This file is automatically generated from the exercises canonical data.

-module(pangram_tests).

-include_lib("erl_exercism/include/exercism.hrl").
-include_lib("eunit/include/eunit.hrl").




'1_empty_sentence_test_'() ->
    {"empty sentence", ?_assertNot(pangram:is_pangram([]))}.

'2_perfect_lower_case_test_'() ->
    {"perfect lower case",
     ?_assert(pangram:is_pangram("abcdefghijklmnopqrstuvwxyz"))}.

'3_only_lower_case_test_'() ->
    {"only lower case",
     ?_assert(pangram:is_pangram("the quick brown fox jumps over the lazy "
				 "dog"))}.

'4_missing_the_letter_x_test_'() ->
    {"missing the letter 'x'",
     ?_assertNot(pangram:is_pangram("a quick movement of the enemy will jeopardize "
				    "five gunboats"))}.

'5_missing_the_letter_h_test_'() ->
    {"missing the letter 'h'",
     ?_assertNot(pangram:is_pangram("five boxing wizards jump quickly at it"))}.

'6_with_underscores_test_'() ->
    {"with underscores",
     ?_assert(pangram:is_pangram("the_quick_brown_fox_jumps_over_the_lazy_dog"))}.

'7_with_numbers_test_'() ->
    {"with numbers",
     ?_assert(pangram:is_pangram("the 1 quick brown fox jumps over the "
				 "2 lazy dogs"))}.

'8_missing_letters_replaced_by_numbers_test_'() ->
    {"missing letters replaced by numbers",
     ?_assertNot(pangram:is_pangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy "
				    "dog"))}.

'9_mixed_case_and_punctuation_test_'() ->
    {"mixed case and punctuation",
     ?_assert(pangram:is_pangram("\"Five quacking Zephyrs jolt my wax "
				 "bed.\""))}.

'10_case_insensitive_test_'() ->
    {"case insensitive",
     ?_assertNot(pangram:is_pangram("the quick brown fox jumps over with "
				    "lazy FX"))}.
-module(pangram).

-export([is_pangram/1]).

is_pangram(Sentence) ->
    Sanitized = [X || X <- string:lowercase(Sentence), $a =< X, X =< $z],
    sets:size(sets:from_list(Sanitized)) == 26.

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?