🛠️ToolsShed

애너그램 체커

두 단어나 문장이 서로의 애너그램인지 확인합니다.

두 단어를 모두 입력하세요.

자주 묻는 질문

코드 구현

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.