ðŸŽ‰ Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io ðŸŽ‰

# SergiiVlasiuk's solution

## to Isogram in the Scala Track

Published at Aug 17 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.

The Scala exercises assume an SBT project scheme. The exercise solution source should be placed within the exercise directory/src/main/scala. The exercise unit tests can be found within the exercise directory/src/test/scala.

To run the tests simply run the command `sbt test` in the exercise directory.

For more detailed info about the Scala track see the help page.

## Submitting Incomplete Solutions

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

### IsogramTest.scala

``````import org.scalatest.{Matchers, FunSuite}

/** @version 1.4.0 */
class IsogramTest extends FunSuite with Matchers {

test("empty string") {
Isogram.isIsogram("") should be(true)
}

test("isogram with only lower case characters") {
pending
Isogram.isIsogram("isogram") should be(true)
}

test("word with one duplicated character") {
pending
Isogram.isIsogram("eleven") should be(false)
}

test("word with one duplicated character from the end of the alphabet") {
pending
Isogram.isIsogram("zzyzx") should be(false)
}

test("longest reported english isogram") {
pending
Isogram.isIsogram("subdermatoglyphic") should be(true)
}

test("word with duplicated character in mixed case") {
pending
Isogram.isIsogram("Alphabet") should be(false)
}

test("hypothetical isogrammic word with hyphen") {
pending
Isogram.isIsogram("thumbscrew-japingly") should be(true)
}

test("isogram with duplicated hyphen") {
pending
Isogram.isIsogram("six-year-old") should be(true)
}

test("made-up name that is an isogram") {
pending
Isogram.isIsogram("Emily Jung Schwartzkopf") should be(true)
}

test("duplicated character in the middle") {
pending
Isogram.isIsogram("accentor") should be(false)
}
}``````
``````object Isogram {
def isIsogram(iso: String): Boolean = {
val cleanedChars = iso.toLowerCase.filter(_.isLetter)
//    val cleanedChars = iso.replaceAll("[^A-z]", "").toLowerCase
//    println(s"\$iso -> [replace all] -> " + iso.replaceAll("[^A-z]", ""))
cleanedChars.length == cleanedChars.distinct.length
}
}``````