forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
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 JuliaLang#42 from aawray/ex-pangram
Add exercise: pangram
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
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
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,2 @@ | ||
ispangram(input::AbstractString) = length(Set(matchall(r"[a-z]", lowercase(input)))) == 26 | ||
|
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,4 @@ | ||
function ispangram(input::AbstractString) | ||
|
||
end | ||
|
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,40 @@ | ||
using Base.Test | ||
|
||
include("pangram.jl") | ||
|
||
@testset "empty sentence" begin | ||
@test !ispangram("") | ||
end | ||
|
||
@testset "pangram with only lower case" begin | ||
@test ispangram("the quick brown fox jumps over the lazy dog") | ||
end | ||
|
||
@testset "missing character 'x'" begin | ||
@test !ispangram("a quick movement of the enemy will jeopardize five gunboats") | ||
end | ||
|
||
@testset "another missing character 'x'" begin | ||
@test !ispangram("the quick brown fish jumps over the lazy dog") | ||
end | ||
|
||
@testset "pangram with underscores" begin | ||
@test ispangram("the_quick_brown_fox_jumps_over_the_lazy_dog") | ||
end | ||
|
||
@testset "pangram with numbers" begin | ||
@test ispangram("the 1 quick brown fox jumps over the 2 lazy dogs") | ||
end | ||
|
||
@testset "missing letters replaced by numbers" begin | ||
@test !ispangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog") | ||
end | ||
|
||
@testset "pangram with mixed case and punctuation" begin | ||
@test ispangram("\"Five quacking Zephyrs jolt my wax bed.\"") | ||
end | ||
|
||
@testset "upper and lower case versions of the same character should not be counted separately" begin | ||
@test !ispangram("the quick brown fox jumped over the lazy FOX") | ||
end | ||
|