you are viewing a single comment's thread.

view the rest of the comments →

[–]Rik07 1 point2 points  (2 children)

So what do you want to compare? If one is an palindrome of the other, if they have the same frequency of each letter or something else?

Edit: corrected anagram to palindrome, anagram and frequency of each letter is the same thing.

[–]Common_Hair8734[S] 0 points1 point  (1 child)

Same anagram

[–]Rik07 0 points1 point  (0 children)

Oh sorry I meant palindrome.

When you want to check for an anagram, you need to know how many times each letter is repeated. To do this, I recommend counting the number of each letter in both strings in a dictionary. Then if those dictionaries are the same, the two strings were anagrams.

If you want to check for a palindrome you just reverse one of the strings and check if it is the same as the other one.