File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 " etl" ,
88 " nucleotide-count" ,
99 " word-count" ,
10+ " pangram" ,
1011 " anagram" ,
1112 " hamming" ,
1213 " bob" ,
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ include 'luhn'
1313include ' meetup'
1414include ' nucleotide-count'
1515include ' octal'
16+ include ' pangram'
1617include ' pascals-triangle'
1718include ' phone-number'
1819include ' pig-latin'
You can’t perform that action at this time.
0 commit comments