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
Empty file added .Rhistory
Empty file.
7 changes: 7 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"language": "Java",
"repository": "https://github.com/exercism/xjava",
"active": true,

"exercises": [
{
"slug": "hello-world",
Expand Down Expand Up @@ -313,6 +314,11 @@
"slug": "ocr-numbers",
"difficulty": 1,
"topics": []
},
{
"slug": "isogram",
"difficulty": 1,
"topics": []
}
],
"deprecated": [
Expand All @@ -335,3 +341,4 @@
"say"
]
}

17 changes: 17 additions & 0 deletions exercises/isogram/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"

repositories {
mavenCentral()
}

dependencies {
testCompile "junit:junit:4.12"
}
test {
testLogging {
exceptionFormat = 'full'
events = ["passed", "failed", "skipped"]
}
}
34 changes: 34 additions & 0 deletions exercises/isogram/src/example/java/IsogramChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package example;

import java.util.HashSet;
import java.util.Set;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.joining;

public class IsogramChecker {

public IsogramChecker(){
}

public boolean isIsogram(String word){

Set<Character> charSet = new HashSet<>();

String[] words = word.split(" ");
String newWord = concat(words);

words = newWord.split("-");
newWord = concat(words).toLowerCase();

for(int i = 0; i < newWord.length(); i++){
charSet.add(newWord.charAt(i));
}

return charSet.size() == newWord.length();
}

private String concat(String[] words){
return stream(words).collect(joining());
}

}
Empty file.
80 changes: 80 additions & 0 deletions exercises/isogram/src/test/java/IsogramTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package test;

import static org.junit.Assert.*;

import org.junit.Ignore;
import org.junit.Test;
import example.IsogramChecker;

public class IsogramTest {

@Test
public void testIsogram() {
IsogramChecker iso = new IsogramChecker();
assertTrue(iso.isIsogram("duplicates"));
}

@Ignore
@Test
public void testNotIsogram() {
IsogramChecker iso = new IsogramChecker();
assertFalse(iso.isIsogram("eleven"));
}

@Ignore
@Test
public void testMediumLongIsogram() {
IsogramChecker iso = new IsogramChecker();
assertTrue(iso.isIsogram("subdermatoglyphic"));
}

@Ignore
@Test
public void testCaseInsensitive() {
IsogramChecker iso = new IsogramChecker();
assertFalse(iso.isIsogram("Alphabet"));
}

@Ignore
@Test
public void testIsogramWithHyphen() {
IsogramChecker iso = new IsogramChecker();
assertTrue(iso.isIsogram("thumbscrew-japingly"));
}

@Ignore
@Test
public void testIgnoresMultipleHyphens() {
IsogramChecker iso = new IsogramChecker();
assertTrue(iso.isIsogram("Hjelmqvist-Gryb-Zock-Pfund-Wax"));
}

@Ignore
@Test
public void testWorksWithGermanLetters() {
IsogramChecker iso = new IsogramChecker();
assertTrue(iso.isIsogram("Heizölrückstoßabdämpfung"));
}

@Ignore
@Test
public void testIgnoresSpaces() {
IsogramChecker iso = new IsogramChecker();
assertFalse(iso.isIsogram("the quick brown fox"));
}

@Ignore
@Test
public void testIgnoresSpaces2() {
IsogramChecker iso = new IsogramChecker();
assertTrue(iso.isIsogram("Emily Jung Schwartzkopf"));
}

@Ignore
@Test
public void testDuplicateAccentedLetters() {
IsogramChecker iso = new IsogramChecker();
assertFalse(iso.isIsogram("éléphant"));
}

}
1 change: 1 addition & 0 deletions exercises/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include 'grade-school'
include 'hamming'
include 'hexadecimal'
include 'hello-world'
include 'isogram'
include 'largest-series-product'
include 'linked-list'
include 'list-ops'
Expand Down