# paulfioravanti's solution

## to Isogram in the Elm Track

Published at Jul 30 2019 · 0 comments
Instructions
Test suite
Solution

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.

## Elm Installation

Refer to the Installing Elm page for information about installing elm.

## Writing the Code

The first time you start an exercise, you'll need to ensure you have the appropriate dependencies installed. Thankfully, Elm makes that easy for you and will install dependencies when you try to run tests or build the code.

Execute the tests with:

``````\$ elm-test
``````

Automatically run tests again when you save changes:

``````\$ elm-test --watch
``````

As you work your way through the test suite, be sure to remove the `skip <|` calls from each test until you get them all passing!

## Submitting Incomplete Solutions

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

### Tests.elm

``````module Tests exposing (tests)

import Expect
import Isogram exposing (isIsogram)
import Test exposing (..)

tests : Test
tests =
describe "Isogram"
[ test "empty string" <|
\() ->
Expect.equal True <| isIsogram ""
, skip <|
test "isogram with only lower case characters" <|
\() ->
Expect.equal True <| isIsogram "isogram"
, skip <|
test "word with one duplicated character" <|
\() ->
Expect.equal False <| isIsogram "eleven"
, skip <|
test "longest reported english isogram" <|
\() ->
Expect.equal True <| isIsogram "subdermatoglyphic"
, skip <|
test "word with duplicated character in mixed case" <|
\() ->
Expect.equal False <| isIsogram "Alphabet"
, skip <|
test "hypothetical isogrammic word with hyphen" <|
\() ->
Expect.equal True <| isIsogram "thumbscrew-japingly"
, skip <|
test "isogram with duplicated non letter character" <|
\() ->
Expect.equal True <| isIsogram "Hjelmqvist-Gryb-Zock-Pfund-Wax"
, skip <|
test "made-up name that is an isogram" <|
\() ->
Expect.equal True <| isIsogram "Emily Jung Schwartzkopf"
, skip <|
test "duplicated character in the middle" <|
\() ->
Expect.equal False <| isIsogram "accentor"
]``````
``````module Isogram exposing (isIsogram)

import Set

isIsogram : String -> Bool
isIsogram sentence =
let
letters =
sentence
|> String.filter Char.isAlpha
|> String.toLower

uniqueLetters =
letters
|> String.toList
|> Set.fromList
in
String.length letters == Set.size uniqueLetters``````