Skip to content

Commit

Permalink
Merge pull request JuliaLang#42 from aawray/ex-pangram
Browse files Browse the repository at this point in the history
Add exercise: pangram
  • Loading branch information
SaschaMann authored Feb 13, 2017
2 parents 8d0d1f2 + e02cac2 commit a514f6c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
11 changes: 10 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"topics": [
"control-flow (conditionals)",
"integers",
"mathematics"
"mathematics"
]
},
{
Expand Down Expand Up @@ -139,6 +139,15 @@
"filtering"
]
},
{
"slug": "pangram",
"difficulty": 1,
"topics": [
"arrays",
"strings",
"filtering"
]
},
{
"slug": "bob",
"difficulty": 2,
Expand Down
2 changes: 2 additions & 0 deletions exercises/pangram/example.jl
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

4 changes: 4 additions & 0 deletions exercises/pangram/pangram.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function ispangram(input::AbstractString)

end

40 changes: 40 additions & 0 deletions exercises/pangram/runtests.jl
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

0 comments on commit a514f6c

Please sign in to comment.