Skip to content

Latest commit

 

History

History
56 lines (29 loc) · 912 Bytes

Anagram_Detection.md

File metadata and controls

56 lines (29 loc) · 912 Bytes

CodeWars Python Solutions


Anagram Detection

An anagram is the result of rearranging the letters of a word to produce a new word (see wikipedia).

Note: anagrams are case insensitive

Complete the function to return true if the two arguments given are anagrams of each other; return false otherwise.

Examples

  • "foefet" is an anagram of "toffee"
  • "Buckethead" is an anagram of "DeathCubeK"

Given Code

def is_anagram(test, original):
    pass

Solution 1

def is_anagram(test, original):
    return set(test.lower()) == set(original.lower()) and len(test) == len(original)

Solution 2

def is_anagram(test, original):
    return sorted(original.lower()) == sorted(test.lower())

See on CodeWars.com