forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the anagrams problem with its test file
- Loading branch information
1 parent
81f26fe
commit dcab675
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / py_lintingRuff (F401)
|
||
|
||
|
||
class TestIsAnagram(unittest.TestCase): | ||
"""Test suite for the is_anagram function""" | ||
# Standard test cases | ||
def test_base(self): | ||
pass |