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
z, inclusive, and is case
insensitive. Input will not contain non-ASCII symbols.
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
Each problem defines a macro
TEST_VERSION in the test file and
verifies that the solution defines and exports a function
returning that same value.
To make tests pass, add the following to your solution:
-export([test_version/0]). test_version() -> 1.
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.
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
-module(pangram_tests). -include_lib("erl_exercism/include/exercism.hrl"). -include_lib("eunit/include/eunit.hrl"). % test cases adapted from `x-common//canonical-data.json` @ version: 1.3.0 empty_sentence_test() -> ?assertNot(pangram:is_pangram("")). perfect_lower_case_pangram_test() -> ?assert(pangram:is_pangram("abcdefghijklmnopqrstuvwxyz")). 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() -> ?assert(pangram:is_pangram("the_quick_brown_fox_jumps_over_the_lazy_dog")). 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")).
-module(pangram). -export([is_pangram/1, test_version/0]). test_version() -> 1. is_pangram(Sentence) -> Alphabet = sets:from_list(lists:seq($a, $z)), sets:is_subset(Alphabet, sets:from_list(string:casefold(Sentence))).
A huge amount can be learnt 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.