Challenge: Anagram Check

Lab Python Beginner 10 points

Read two words and print anagram if they use exactly the same letters (ignoring capital letters), otherwise not anagram. Count the letters with a dictionary or Counter.

Input

Two lines, one word on each.

Output

anagram or not anagram.

Example

Input

listen
silent

Output

anagram
Sample input available Sample output available
Editor
Python

Hints

Lower-case both words first.

Counter(a) == Counter(b) compares letter counts.

Solution explanation

Counting letters is O(n), faster than sorting both words.

Show solution
from collections import Counter
a = input().strip().lower()
b = input().strip().lower()
print("anagram" if Counter(a) == Counter(b) else "not anagram")
Output
Answer
HOME LABS COMMUNITY DASHBOARD