Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"etl",
"nucleotide-count",
"word-count",
"pangram",
"anagram",
"hamming",
"bob",
Expand Down
11 changes: 11 additions & 0 deletions pangram/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"

repositories {
mavenCentral()
}

dependencies {
testCompile "junit:junit:4.10"
}
12 changes: 12 additions & 0 deletions pangram/src/example/java/Pangrams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import java.util.Arrays;
import java.util.stream.Collectors;

public class Pangrams {
private static final int alphaLength = 26;

public static boolean isPangram(String input){
return Arrays.stream(input.replaceAll("[^a-zA-Z]","").toLowerCase().split(""))
.collect(Collectors.toSet())
.size() == alphaLength;
}
}
Empty file added pangram/src/main/java/.keep
Empty file.
Empty file added pangram/src/test/java/.keep
Empty file.
33 changes: 33 additions & 0 deletions pangram/src/test/java/PangramTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import org.junit.Test;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;

public class PangramTest {

@Test
public void emptySentence() {
assertFalse(Pangrams.isPangram(""));
}

@Test
public void testLowercasePangram() {
assertTrue(Pangrams.isPangram("the quick brown fox jumps over the lazy dog"));
}

@Test
public void missingCharacterX() {
assertFalse(Pangrams.isPangram("a quick movement of the enemy will jeopardize five gunboats"));
}

@Test
public void mixedCaseAndPunctuation() {
assertTrue(Pangrams.isPangram("\"Five quacking Zephyrs jolt my wax bed.\""));
}

@Test
public void nonAsciiCharacters() {
assertTrue(Pangrams.isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich."));
}

}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include 'luhn'
include 'meetup'
include 'nucleotide-count'
include 'octal'
include 'pangram'
include 'pascals-triangle'
include 'phone-number'
include 'pig-latin'
Expand Down