#579 · Strings · Intermediate · Review the AI's code · 60 XP · about 7 min
Someone asked an AI assistant: "Write a function that checks whether two phrases are anagrams of each other, ignoring case and spaces." This is its answer. It looks right, but it has a bug.
is_anagram(a, b) should return True when the letters of a can be rearranged to spell the letters of b, using every letter exactly as many times as it appears, and False otherwise. Upper and lower case count as the same letter, and spaces are ignored.
is_anagram('Listen', 'Silent') # returns True is_anagram('Dormitory', 'Dirty room') # returns True is_anagram('apple', 'paper') # returns False
First solves only, ranked by stars and then time.