Sha256: cd7b82898894f333654bb5abf6dbe0ee1cc5da7228973dd57ee5de6ff1017dee

Contents?: true

Size: 417 Bytes

Versions: 126

Compression:

Stored size: 417 Bytes

Contents

class Anagram(private val word: String) {

    fun match(anagrams: Collection<String>) =
            anagrams.filter { containSameChars(it.toLowerCase()) }
                    .filterNot { it.equals(word, ignoreCase = true) }
                    .toSet()

    private fun containSameChars(candidate: String) =
            candidate.toLowerCase().toCharArray().sorted() == word.toLowerCase().toCharArray().sorted()

}

Version data entries

126 entries across 126 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.138 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.137 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.136 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.135 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.134 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.133 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.132 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.131 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.130 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.129 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.128 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.127 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.126 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.125 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.124 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.123 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.122 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.121 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt
trackler-2.2.1.120 tracks/kotlin/exercises/anagram/.meta/src/reference/kotlin/Anagram.kt