Skip to content

Commit 1861692

Browse files
committed
Merge pull request exercism#70 from matthewmorgan/new-exercise-pangram
Add new exercise pangram
2 parents ff0b929 + 368a983 commit 1861692

7 files changed

Lines changed: 58 additions & 0 deletions

File tree

‎config.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"etl",
88
"nucleotide-count",
99
"word-count",
10+
"pangram",
1011
"anagram",
1112
"hamming",
1213
"bob",

‎pangram/build.gradle‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apply plugin: "java"
2+
apply plugin: "eclipse"
3+
apply plugin: "idea"
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
testCompile "junit:junit:4.10"
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import java.util.Arrays;
2+
import java.util.stream.Collectors;
3+
4+
public class Pangrams {
5+
private static final int alphaLength = 26;
6+
7+
public static boolean isPangram(String input){
8+
return Arrays.stream(input.replaceAll("[^a-zA-Z]","").toLowerCase().split(""))
9+
.collect(Collectors.toSet())
10+
.size() == alphaLength;
11+
}
12+
}

‎pangram/src/main/java/.keep‎

Whitespace-only changes.

‎pangram/src/test/java/.keep‎

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import org.junit.Test;
2+
3+
import static org.junit.Assert.assertTrue;
4+
import static org.junit.Assert.assertFalse;
5+
6+
public class PangramTest {
7+
8+
@Test
9+
public void emptySentence() {
10+
assertFalse(Pangrams.isPangram(""));
11+
}
12+
13+
@Test
14+
public void testLowercasePangram() {
15+
assertTrue(Pangrams.isPangram("the quick brown fox jumps over the lazy dog"));
16+
}
17+
18+
@Test
19+
public void missingCharacterX() {
20+
assertFalse(Pangrams.isPangram("a quick movement of the enemy will jeopardize five gunboats"));
21+
}
22+
23+
@Test
24+
public void mixedCaseAndPunctuation() {
25+
assertTrue(Pangrams.isPangram("\"Five quacking Zephyrs jolt my wax bed.\""));
26+
}
27+
28+
@Test
29+
public void nonAsciiCharacters() {
30+
assertTrue(Pangrams.isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich."));
31+
}
32+
33+
}

‎settings.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include 'luhn'
1313
include 'meetup'
1414
include 'nucleotide-count'
1515
include 'octal'
16+
include 'pangram'
1617
include 'pascals-triangle'
1718
include 'phone-number'
1819
include 'pig-latin'

0 commit comments

Comments
 (0)