diff --git a/solutions/anagrams.py b/solutions/anagrams.py new file mode 100644 index 000000000..0cd75a3f3 --- /dev/null +++ b/solutions/anagrams.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Write a function that takes two strings as input and checks if they +are anagrams of each other. Anagrams are words or phrases made by +rearranging the letters of another, using all original letters +exactly once + +True if the two strings are anagrams, False otherwise + +""" + + +def is_anagrams(word1: str, word2: str) -> bool: + """ + Returns true or false if the two strings given are anagrams + of each other. + + Parameters: + word1: The first string + words2: The second string + + Returns -> bool: Either true or false of either the strings + are anagrams of each other or not. + + Raises: + AssertionError: if the parameters are not strings + + Examples: + >>> is_anagrams("anagram", "nagaram") + True + >>> is_anagrams("rat", "car") + False + """ diff --git a/solutions/tests/test_anagrams.py b/solutions/tests/test_anagrams.py new file mode 100644 index 000000000..71346393d --- /dev/null +++ b/solutions/tests/test_anagrams.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Test module for find_longest function. +Contains correct tests to help identify bugs in the implementation. + +Test categories: + - Standard cases: typical string lists + - Edge cases: empty strings, equal lengths + - Defensive tests: invalid inputs + +Created on 2024-12-06 +Author: Claude AI +""" + + +import unittest + +from ..anagrams import is_anagrams + + +class TestIsAnagram(unittest.TestCase): + """Test suite for the is_anagram function""" + # Standard test cases + def test_base(self): + pass