Anagram

in ita •  8 months ago 

import java.util.Arrays
class Anagram {

String word
Anagram(String word){
    this.word = word
}

def isAnagram(candidate){
    if (candidate.equalsIgnoreCase(word)) return false
    char [] cand = candidate.toLowerCase().toCharArray()
    char [] wor = word.toLowerCase().toCharArray()
    Arrays.sort(cand)
    Arrays.sort(wor)
    return Arrays.equals(cand, wor)
}

def find(candidates) {
    String [] candV = []
    def cand = candV.toList()
    candidates.each { candidate ->
        if(isAnagram(candidate)){
            cand.add(candidate)
        }
    }
    return cand
}

}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.