Avatar of 4d47

4d47's solution

to Isogram 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 word or phrase is an isogram.

An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.

Examples of isograms:

  • lumberjacks
  • background
  • downstream
  • six-year-old

The word isograms, however, is not an isogram, because the s repeats.

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/Isogram

Submitting Incomplete Solutions

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




empty_string_test() ->

isogram_with_only_lower_case_characters_test() ->

word_with_one_duplicated_character_test() ->

longest_reported_english_isogram_test() ->

word_with_duplicated_character_in_mixed_case_test() ->

hypothetical_isogrammic_word_with_hyphen_test() ->

isogram_with_duplicated_hyphen_test() ->

made_up_name_that_is_an_isogram_test() ->
    ?assert(isogram:is_isogram("Emily Jung Schwartzkopf")).

duplicated_character_in_the_middle_test() ->

version_test() ->
  ?assertMatch(1, isogram:test_version()).
-export([is_isogram/1, test_version/0]).

test_version() ->

is_isogram(String) ->
    S = string:lowercase(String),
    Alphabet = sets:from_list(lists:seq($a, $z)),
    Letters = [ C || C <- S, sets:is_element(C, Alphabet) ],
    length(Letters) == sets:size(sets:from_list(Letters)).

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?