-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from ErikSchierboom/pangram
Add pangram exercise
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
"clock", | ||
"series", | ||
"strain", | ||
"pangram", | ||
"atbash-cipher", | ||
"grade-school", | ||
"raindrops", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Pangram | ||
|
||
let isPangram (input: string) = | ||
let normalized = input.ToLowerInvariant() | ||
|
||
['a'..'z'] |> List.forall (fun l -> normalized.Contains(l.ToString())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module PangramTest | ||
|
||
open NUnit.Framework | ||
|
||
open Pangram | ||
|
||
[<Test>] | ||
let ``Empty sentence`` () = | ||
let input = "" | ||
Assert.That(isPangram input, Is.False) | ||
|
||
[<Test>] | ||
[<Ignore("Remove to run test")>] | ||
let ``Pangram with only lower case`` () = | ||
let input = "the quick brown fox jumps over the lazy dog" | ||
Assert.That(isPangram input, Is.True) | ||
|
||
[<Test>] | ||
[<Ignore("Remove to run test")>] | ||
let ``Missing character 'x'`` () = | ||
let input = "a quick movement of the enemy will jeopardize five gunboats" | ||
Assert.That(isPangram input, Is.False) | ||
|
||
[<Test>] | ||
[<Ignore("Remove to run test")>] | ||
let ``Pangram with mixed case and punctuation`` () = | ||
let input = "\"Five quacking Zephyrs jolt my wax bed.\"" | ||
Assert.That(isPangram input, Is.True) | ||
|
||
[<Test>] | ||
[<Ignore("Remove to run test")>] | ||
let ``Pangram with non ascii characters`` () = | ||
let input = "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich." | ||
Assert.That(isPangram input, Is.True) |