diff --git a/kotlin/anagram/.gradle/3.5/file-changes/last-build.bin b/kotlin/anagram/.gradle/3.5/file-changes/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/kotlin/anagram/.gradle/3.5/file-changes/last-build.bin differ diff --git a/kotlin/anagram/.gradle/3.5/taskHistory/taskHistory.lock b/kotlin/anagram/.gradle/3.5/taskHistory/taskHistory.lock new file mode 100644 index 0000000..8ce84d1 Binary files /dev/null and b/kotlin/anagram/.gradle/3.5/taskHistory/taskHistory.lock differ diff --git a/kotlin/accumulate/build/kotlin/daemon-is-alive b/kotlin/anagram/.gradle/buildOutputCleanup/built.bin similarity index 100% rename from kotlin/accumulate/build/kotlin/daemon-is-alive rename to kotlin/anagram/.gradle/buildOutputCleanup/built.bin diff --git a/kotlin/anagram/.gradle/buildOutputCleanup/cache.properties b/kotlin/anagram/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..5454512 --- /dev/null +++ b/kotlin/anagram/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Sun Jun 04 21:03:52 EDT 2017 +gradle.version=3.5 diff --git a/kotlin/anagram/.gradle/buildOutputCleanup/cache.properties.lock b/kotlin/anagram/.gradle/buildOutputCleanup/cache.properties.lock new file mode 100644 index 0000000..40fdece --- /dev/null +++ b/kotlin/anagram/.gradle/buildOutputCleanup/cache.properties.lock @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/kotlin/anagram/.idea/compiler.xml b/kotlin/anagram/.idea/compiler.xml new file mode 100644 index 0000000..c7faf30 --- /dev/null +++ b/kotlin/anagram/.idea/compiler.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/gradle.xml b/kotlin/anagram/.idea/gradle.xml new file mode 100644 index 0000000..20d2df6 --- /dev/null +++ b/kotlin/anagram/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/libraries/Gradle__junit_junit_4_12.xml b/kotlin/anagram/.idea/libraries/Gradle__junit_junit_4_12.xml new file mode 100644 index 0000000..04c10dd --- /dev/null +++ b/kotlin/anagram/.idea/libraries/Gradle__junit_junit_4_12.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml b/kotlin/anagram/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..8262f72 --- /dev/null +++ b/kotlin/anagram/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml new file mode 100644 index 0000000..4f32fde --- /dev/null +++ b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_1.xml b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_1.xml new file mode 100644 index 0000000..7b6f562 --- /dev/null +++ b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_1_1_1.xml b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_1_1_1.xml new file mode 100644 index 0000000..1720158 --- /dev/null +++ b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_1_1_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_junit_1_1_1.xml b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_junit_1_1_1.xml new file mode 100644 index 0000000..21c5d19 --- /dev/null +++ b/kotlin/anagram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_junit_1_1_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/misc.xml b/kotlin/anagram/.idea/misc.xml new file mode 100644 index 0000000..84da703 --- /dev/null +++ b/kotlin/anagram/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/modules.xml b/kotlin/anagram/.idea/modules.xml new file mode 100644 index 0000000..1573a32 --- /dev/null +++ b/kotlin/anagram/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/modules/anagram_main.iml b/kotlin/anagram/.idea/modules/anagram_main.iml new file mode 100644 index 0000000..325406c --- /dev/null +++ b/kotlin/anagram/.idea/modules/anagram_main.iml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/modules/anagram_test.iml b/kotlin/anagram/.idea/modules/anagram_test.iml new file mode 100644 index 0000000..990324f --- /dev/null +++ b/kotlin/anagram/.idea/modules/anagram_test.iml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/.idea/workspace.xml b/kotlin/anagram/.idea/workspace.xml new file mode 100644 index 0000000..f79b7a1 --- /dev/null +++ b/kotlin/anagram/.idea/workspace.xml @@ -0,0 +1,899 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Ignore + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1496624614733 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/README.md b/kotlin/anagram/README.md new file mode 100644 index 0000000..ec01c37 --- /dev/null +++ b/kotlin/anagram/README.md @@ -0,0 +1,15 @@ +# Anagram + +Given a word and a list of possible anagrams, select the correct sublist. + +Given `"listen"` and a list of candidates like `"enlists" "google" +"inlets" "banana"` the program should return a list containing +`"inlets"`. + +## Source + +Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + diff --git a/kotlin/anagram/anagram.iml b/kotlin/anagram/anagram.iml new file mode 100644 index 0000000..b22a1b6 --- /dev/null +++ b/kotlin/anagram/anagram.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/anagram/build.gradle b/kotlin/anagram/build.gradle new file mode 100644 index 0000000..16c36c0 --- /dev/null +++ b/kotlin/anagram/build.gradle @@ -0,0 +1,28 @@ +buildscript { + ext.kotlin_version = '1.1.1' + repositories { + mavenCentral() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' + +repositories { + mavenCentral() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + + testCompile 'junit:junit:4.12' + testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" +} +test { + testLogging { + exceptionFormat = 'full' + events = ["passed", "failed", "skipped"] + } +} diff --git a/kotlin/anagram/build/classes/main/Anagram$letterMap$2.class b/kotlin/anagram/build/classes/main/Anagram$letterMap$2.class new file mode 100644 index 0000000..2161a8a Binary files /dev/null and b/kotlin/anagram/build/classes/main/Anagram$letterMap$2.class differ diff --git a/kotlin/anagram/build/classes/main/Anagram.class b/kotlin/anagram/build/classes/main/Anagram.class new file mode 100644 index 0000000..5f2cc8a Binary files /dev/null and b/kotlin/anagram/build/classes/main/Anagram.class differ diff --git a/kotlin/anagram/build/classes/test/AnagramTest.class b/kotlin/anagram/build/classes/test/AnagramTest.class new file mode 100644 index 0000000..5da8339 Binary files /dev/null and b/kotlin/anagram/build/classes/test/AnagramTest.class differ diff --git a/kotlin/anagram/build/kotlin-build/caches/version.txt b/kotlin/anagram/build/kotlin-build/caches/version.txt new file mode 100644 index 0000000..01aabac --- /dev/null +++ b/kotlin/anagram/build/kotlin-build/caches/version.txt @@ -0,0 +1 @@ +11001 \ No newline at end of file diff --git a/kotlin/anagram/src/main/kotlin/.keep b/kotlin/anagram/src/main/kotlin/.keep new file mode 100644 index 0000000..e69de29 diff --git a/kotlin/anagram/src/main/kotlin/Anagram.kt b/kotlin/anagram/src/main/kotlin/Anagram.kt new file mode 100644 index 0000000..d9f7a97 --- /dev/null +++ b/kotlin/anagram/src/main/kotlin/Anagram.kt @@ -0,0 +1,28 @@ +class Anagram(val internalString: String) { + val letterMap: Map by lazy { + val temp = emptyMap().toMutableMap(); + for (i in internalString){ + if (temp.containsKey(i)){ + temp.put(i.toLowerCase(), temp[i]!!.inc()) + } + else temp.put(i.toLowerCase(), 1) + } + temp + } + + fun match(wordList: List): List{ + return wordList.filter { isAnagram(it) } + } + + private fun isAnagram(candidate: String): Boolean{ + if (internalString.toLowerCase() == candidate.toLowerCase()) return false + val candidateLetterMap = emptyMap().toMutableMap() + for (i in candidate){ + if (candidateLetterMap.containsKey(i)){ + candidateLetterMap.put(i.toLowerCase(), candidateLetterMap[i]!!.inc()) + } + else candidateLetterMap.put(i.toLowerCase(), 1) + } + return candidateLetterMap == letterMap + } +} \ No newline at end of file diff --git a/kotlin/anagram/src/test/kotlin/AnagramTest.kt b/kotlin/anagram/src/test/kotlin/AnagramTest.kt new file mode 100644 index 0000000..8a76f00 --- /dev/null +++ b/kotlin/anagram/src/test/kotlin/AnagramTest.kt @@ -0,0 +1,84 @@ +import org.junit.Test +import org.junit.Ignore +import kotlin.test.assertEquals + +class AnagramTest { + + + @Test + fun noMatches() { + val detector = Anagram("diaper") + assertEquals(listOf(), detector.match(listOf("hello", "world", "zombies", "pants"))) + } + + + @Test + fun simpleAnagram() { + val detector = Anagram("ant") + val anagram = detector.match(listOf("tan", "stand", "at")) + assertEquals(listOf("tan"), anagram) + } + + + @Test + fun detectMultipleAnagrams() { + val detector = Anagram("master") + val anagrams = detector.match(listOf("stream", "pigeon", "maters")) + assertEquals(listOf("maters", "stream"), anagrams.sorted()) + } + + + @Test + fun doesNotConfuseDifferentDuplicates() { + val detector = Anagram("galea") + val anagrams = detector.match(listOf("eagle")) + assertEquals(listOf(), anagrams) + } + + + @Test + fun identicalWordIsNotAnagram() { + val detector = Anagram("corn") + val anagrams = detector.match(listOf("corn", "dark", "Corn", "rank", "CORN", "cron", "park")) + assertEquals(listOf("cron"), anagrams) + } + + + @Test + fun eliminateAnagramsWithSameChecksum() { + val detector = Anagram("mass") + assertEquals(listOf(), detector.match(listOf("last"))) + } + + + @Test + fun eliminateAnagramSubsets() { + val detector = Anagram("good") + assertEquals(listOf(), detector.match(listOf("dog", "goody"))) + } + + + @Test + fun detectAnagrams() { + val detector = Anagram("listen") + val anagrams = detector.match(listOf("enlists", "google", "inlets", "banana")) + assertEquals(listOf("inlets"), anagrams) + } + + + @Test + fun multipleAnagrams() { + val detector = Anagram("allergy") + val anagrams = detector.match(listOf("gallery", "ballerina", "regally", "clergy", "largely", "leading")) + assertEquals(listOf("gallery", "largely", "regally"), anagrams.sorted()) + } + + + @Test + fun anagramsAreCaseInsensitive() { + val detector = Anagram("Orchestra") + val anagrams = detector.match(listOf("cashregister", "Carthorse", "radishes")) + assertEquals(listOf("Carthorse"), anagrams) + } + +} diff --git a/kotlin/isogram/.gradle/3.5/file-changes/last-build.bin b/kotlin/isogram/.gradle/3.5/file-changes/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/kotlin/isogram/.gradle/3.5/file-changes/last-build.bin differ diff --git a/kotlin/isogram/.gradle/3.5/taskHistory/taskHistory.lock b/kotlin/isogram/.gradle/3.5/taskHistory/taskHistory.lock new file mode 100644 index 0000000..d638edb Binary files /dev/null and b/kotlin/isogram/.gradle/3.5/taskHistory/taskHistory.lock differ diff --git a/kotlin/isogram/.gradle/buildOutputCleanup/built.bin b/kotlin/isogram/.gradle/buildOutputCleanup/built.bin new file mode 100644 index 0000000..e69de29 diff --git a/kotlin/isogram/.gradle/buildOutputCleanup/cache.properties b/kotlin/isogram/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..0ab6d2f --- /dev/null +++ b/kotlin/isogram/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Sun Jun 04 21:56:37 EDT 2017 +gradle.version=3.5 diff --git a/kotlin/isogram/.gradle/buildOutputCleanup/cache.properties.lock b/kotlin/isogram/.gradle/buildOutputCleanup/cache.properties.lock new file mode 100644 index 0000000..40fdece --- /dev/null +++ b/kotlin/isogram/.gradle/buildOutputCleanup/cache.properties.lock @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/kotlin/isogram/.idea/compiler.xml b/kotlin/isogram/.idea/compiler.xml new file mode 100644 index 0000000..2384a48 --- /dev/null +++ b/kotlin/isogram/.idea/compiler.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/gradle.xml b/kotlin/isogram/.idea/gradle.xml new file mode 100644 index 0000000..20d2df6 --- /dev/null +++ b/kotlin/isogram/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/libraries/Gradle__junit_junit_4_12.xml b/kotlin/isogram/.idea/libraries/Gradle__junit_junit_4_12.xml new file mode 100644 index 0000000..04c10dd --- /dev/null +++ b/kotlin/isogram/.idea/libraries/Gradle__junit_junit_4_12.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml b/kotlin/isogram/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..8262f72 --- /dev/null +++ b/kotlin/isogram/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml new file mode 100644 index 0000000..4f32fde --- /dev/null +++ b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_1.xml b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_1.xml new file mode 100644 index 0000000..7b6f562 --- /dev/null +++ b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_1_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_1_1_1.xml b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_1_1_1.xml new file mode 100644 index 0000000..1720158 --- /dev/null +++ b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_1_1_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_junit_1_1_1.xml b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_junit_1_1_1.xml new file mode 100644 index 0000000..21c5d19 --- /dev/null +++ b/kotlin/isogram/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_test_junit_1_1_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/misc.xml b/kotlin/isogram/.idea/misc.xml new file mode 100644 index 0000000..84da703 --- /dev/null +++ b/kotlin/isogram/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/modules.xml b/kotlin/isogram/.idea/modules.xml new file mode 100644 index 0000000..3123a70 --- /dev/null +++ b/kotlin/isogram/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/modules/isogram_main.iml b/kotlin/isogram/.idea/modules/isogram_main.iml new file mode 100644 index 0000000..9be7fcf --- /dev/null +++ b/kotlin/isogram/.idea/modules/isogram_main.iml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/modules/isogram_test.iml b/kotlin/isogram/.idea/modules/isogram_test.iml new file mode 100644 index 0000000..ec8ab1d --- /dev/null +++ b/kotlin/isogram/.idea/modules/isogram_test.iml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/.idea/workspace.xml b/kotlin/isogram/.idea/workspace.xml new file mode 100644 index 0000000..35c25ea --- /dev/null +++ b/kotlin/isogram/.idea/workspace.xml @@ -0,0 +1,878 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1496627789651 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/README.md b/kotlin/isogram/README.md new file mode 100644 index 0000000..c21c931 --- /dev/null +++ b/kotlin/isogram/README.md @@ -0,0 +1,21 @@ +# Isogram + +Determine if a word or phrase is an isogram. + +An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter. + +Examples of isograms: + +- lumberjacks +- background +- downstream + +The word *isograms*, however, is not an isogram, because the s repeats. + +## Source + +Wikipedia [https://en.wikipedia.org/wiki/Isogram](https://en.wikipedia.org/wiki/Isogram) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + diff --git a/kotlin/isogram/build.gradle b/kotlin/isogram/build.gradle new file mode 100644 index 0000000..16c36c0 --- /dev/null +++ b/kotlin/isogram/build.gradle @@ -0,0 +1,28 @@ +buildscript { + ext.kotlin_version = '1.1.1' + repositories { + mavenCentral() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' + +repositories { + mavenCentral() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + + testCompile 'junit:junit:4.12' + testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" +} +test { + testLogging { + exceptionFormat = 'full' + events = ["passed", "failed", "skipped"] + } +} diff --git a/kotlin/isogram/build/classes/main/Isogram.class b/kotlin/isogram/build/classes/main/Isogram.class new file mode 100644 index 0000000..a3368e5 Binary files /dev/null and b/kotlin/isogram/build/classes/main/Isogram.class differ diff --git a/kotlin/isogram/build/classes/main/IsogramKt$toFrequencyMap$$inlined$groupingBy$1.class b/kotlin/isogram/build/classes/main/IsogramKt$toFrequencyMap$$inlined$groupingBy$1.class new file mode 100644 index 0000000..4845f1c Binary files /dev/null and b/kotlin/isogram/build/classes/main/IsogramKt$toFrequencyMap$$inlined$groupingBy$1.class differ diff --git a/kotlin/isogram/build/classes/main/IsogramKt.class b/kotlin/isogram/build/classes/main/IsogramKt.class new file mode 100644 index 0000000..f96d875 Binary files /dev/null and b/kotlin/isogram/build/classes/main/IsogramKt.class differ diff --git a/kotlin/isogram/build/classes/main/META-INF/isogram_main.kotlin_module b/kotlin/isogram/build/classes/main/META-INF/isogram_main.kotlin_module new file mode 100644 index 0000000..62a9da8 Binary files /dev/null and b/kotlin/isogram/build/classes/main/META-INF/isogram_main.kotlin_module differ diff --git a/kotlin/isogram/build/classes/test/IsogramTest$Companion.class b/kotlin/isogram/build/classes/test/IsogramTest$Companion.class new file mode 100644 index 0000000..b7974f9 Binary files /dev/null and b/kotlin/isogram/build/classes/test/IsogramTest$Companion.class differ diff --git a/kotlin/isogram/build/classes/test/IsogramTest.class b/kotlin/isogram/build/classes/test/IsogramTest.class new file mode 100644 index 0000000..6417dd4 Binary files /dev/null and b/kotlin/isogram/build/classes/test/IsogramTest.class differ diff --git a/kotlin/isogram/build/kotlin-build/caches/version.txt b/kotlin/isogram/build/kotlin-build/caches/version.txt new file mode 100644 index 0000000..01aabac --- /dev/null +++ b/kotlin/isogram/build/kotlin-build/caches/version.txt @@ -0,0 +1 @@ +11001 \ No newline at end of file diff --git a/kotlin/isogram/isogram.iml b/kotlin/isogram/isogram.iml new file mode 100644 index 0000000..c87a6ba --- /dev/null +++ b/kotlin/isogram/isogram.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/kotlin/isogram/src/main/kotlin/.keep b/kotlin/isogram/src/main/kotlin/.keep new file mode 100644 index 0000000..e69de29 diff --git a/kotlin/isogram/src/main/kotlin/Isogram.kt b/kotlin/isogram/src/main/kotlin/Isogram.kt new file mode 100644 index 0000000..02bab4d --- /dev/null +++ b/kotlin/isogram/src/main/kotlin/Isogram.kt @@ -0,0 +1,9 @@ +fun String.toFrequencyMap(): Map = this.groupingBy{it.toLowerCase()}.eachCount() + +object Isogram { + fun isIsogram(inpString: String): Boolean{ + val frequencyMap: Map = inpString.toFrequencyMap() + frequencyMap.filter { it.key.isLetter() } + return frequencyMap.values.none { it > 1 } + } +} \ No newline at end of file diff --git a/kotlin/isogram/src/test/kotlin/IsogramTest.kt b/kotlin/isogram/src/test/kotlin/IsogramTest.kt new file mode 100644 index 0000000..5eaf71b --- /dev/null +++ b/kotlin/isogram/src/test/kotlin/IsogramTest.kt @@ -0,0 +1,33 @@ + +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith +import org.junit.runners.Parameterized +import kotlin.test.assertEquals + +@RunWith(Parameterized::class) +class IsogramTest(val input: String, val expectedOutput: Boolean) { + + companion object { + @JvmStatic + @Parameterized.Parameters(name = "{index}: isogram({0})={1}") + fun data() = listOf( + arrayOf("duplicates", true), + arrayOf("eleven", false), + arrayOf("subdermatoglyphic", true), + arrayOf("Alphabet", false), + arrayOf("thumbscrew-japingly", true), + arrayOf("Hjelmqvist-Gryb-Zock-Pfund-Wax", true), + arrayOf("Heizölrückstoßabdämpfung", true), + arrayOf("the quick brown fox", false), + arrayOf("Emily Jung Schwartzkopf", true), + arrayOf("éléphant", false) + ) + } + + + @Test + fun test() { + assertEquals(expectedOutput, Isogram.isIsogram(input)) + } +} diff --git a/kotlin/pangram/.idea/workspace.xml b/kotlin/pangram/.idea/workspace.xml index 54839ac..0eaba50 100644 --- a/kotlin/pangram/.idea/workspace.xml +++ b/kotlin/pangram/.idea/workspace.xml @@ -18,12 +18,12 @@ - + - - + + @@ -420,9 +420,6 @@ - - - @@ -481,11 +478,14 @@ + + + - + @@ -815,36 +816,36 @@ - - + - - - - - - - - - + + + + + + + - + - + - + - + + - + + @@ -859,6 +860,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -880,8 +908,8 @@ - - + +