Hackbright Code Challenges

Anagram of Palindrome

Anagram of Palindrome

Whiteboard

Medium

Challenge

Easier

Concepts

Dictionaries, General

Download

anagram-of-palindrome.zip

Solution

Anagram of Palindrome: Solution


Is the word an anagram of a palindrome?

A palindrome is a word that reads the same forward and backwards (eg, “racecar”, “tacocat”). An anagram is a rescrambling of a word (eg for “racecar”, you could rescramble this as “arceace”).

Determine if the given word is a re-scrambling of a palindrome.

The word will only contain lowercase letters, a-z.

Don’t Care If It’s Real

You don’t need to worry about whether it’s an actual English word or not—just whether a palindrome could be made of it.

For example, the word “bcbc” could be rearranged as “bccb”, so this should be true, even though “bccb” isn’t an actual English word.

For example:

>>> is_anagram_of_palindrome("a")
True

>>> is_anagram_of_palindrome("ab")
False

>>> is_anagram_of_palindrome("aab")
True

>>> is_anagram_of_palindrome("arceace")
True

>>> is_anagram_of_palindrome("arceaceb")
False

We’ve given you a file, anagramofpalindrome.py with a function is_anagram_of_palindrome:

anagramofpalindrome.py
def is_anagram_of_palindrome(word):
    """Is the word an anagram of a palindrome?"""

However, this is unimplemented.