Skip to content
Open
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
23 changes: 22 additions & 1 deletion app/src/main/java/com/mouredev/weeklychallenge2022/Challenge1.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ package com.mouredev.weeklychallenge2022
*
*/

fun main() {


fun check(word1: String, word2: String): Boolean{
if (word1 == word2){
print("$word1 & $word2 are the same word")
return false
}
if(word1.alphabetized() == word2.alphabetized()){
print("$word1 & $word2 are anagrams")
return true
}else{
print("$word1 & $word2 are not anagrams")
return false
}

}

fun main() {
val word1 = "night"
val word2 = "thing"
check(word1, word2)
}

fun String.alphabetized() = String(toCharArray().apply { sort() })