Editor

Anagram Check

#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.

Examples

is_anagram('Listen', 'Silent')         # returns True
is_anagram('Dormitory', 'Dirty room')  # returns True
is_anagram('apple', 'paper')           # returns False

Constraints

  • Each phrase has 0 to 100 characters, all letters or spaces.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.