Skip to content

Commit

Permalink
Added the anagrams problem with its test file
Browse files Browse the repository at this point in the history
  • Loading branch information
reunicorn1 committed Dec 30, 2024
1 parent 81f26fe commit dcab675
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
34 changes: 34 additions & 0 deletions solutions/anagrams.py
Original file line number Diff line number Diff line change
@@ -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
"""
26 changes: 26 additions & 0 deletions solutions/tests/test_anagrams.py
Original file line number Diff line number Diff line change
@@ -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

Check failure on line 19 in solutions/tests/test_anagrams.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F401)

solutions/tests/test_anagrams.py:19:24: F401 `..anagrams.is_anagrams` imported but unused

Check failure on line 19 in solutions/tests/test_anagrams.py

View workflow job for this annotation

GitHub Actions / py_linting

Ruff (F401)

solutions/tests/test_anagrams.py:19:24: F401 `..anagrams.is_anagrams` imported but unused


class TestIsAnagram(unittest.TestCase):
"""Test suite for the is_anagram function"""
# Standard test cases
def test_base(self):
pass

0 comments on commit dcab675

Please sign in to comment.