πŸ› οΈToolsShed

Anagram Solver

Check if two words or phrases are anagrams of each other and find all anagrams.

Enter both words to check.

Frequently Asked Questions

Code Implementation

from itertools import permutations

def get_anagrams(letters: str, word_list: list[str]) -> list[str]:
    """Find all words that are anagrams of the given letters."""
    sorted_letters = sorted(letters.lower())
    anagrams = []
    for word in word_list:
        if sorted(word.lower()) == sorted_letters:
            anagrams.append(word)
    return anagrams

# Example usage
words = ["listen", "silent", "enlist", "hello", "world", "inlets"]
result = get_anagrams("listen", words)
print(result)  # ['listen', 'silent', 'enlist', 'inlets']

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.