Skip to content

Add Assignment #1 – Anagram Checker solution#1

Open
katariamonika wants to merge 1 commit intomainfrom
assignment-1
Open

Add Assignment #1 – Anagram Checker solution#1
katariamonika wants to merge 1 commit intomainfrom
assignment-1

Conversation

@katariamonika
Copy link
Owner

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

Added assignment_1.ipynb implementing an Anagram Checker:

  • Part 1: anagram_checker(word_a, word_b) (case-insensitive by default)
  • Part 2: extended to anagram_checker(word_a, word_b, is_case_sensitive) to optionally enforce case sensitivity
  • Included clear comments and a few sample tests in cells
    No other files were changed.

What did you learn from the changes you have made?

  • Normalizing strings (e.g., lower()) before comparison
  • Two valid strategies to detect anagrams: sorting vs. counting characters
  • Writing small, testable functions in a Jupyter notebook and validating outputs

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

Yes:

  1. Use collections.Counter to compare character frequencies instead of sorting.
  2. Strip spaces/punctuation before comparing (not required here, but considered for robustness).
    I chose sorting for simplicity and readability.

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

  • Making sure the correct kernel (Python 3 / ipykernel) was selected in VS Code.
  • Remembering that sorted() returns lists and comparing those directly works.
    Resolved by selecting the “base (Python 3.x)” kernel and adding quick print/tests in cells.

How were these changes tested?

  • Ran the provided examples and additional edge cases:
    • Different lengths (should be False)
    • Same words (should be True)
    • Case-sensitive vs. case-insensitive checks
      All cells execute without errors and outputs match expectations.

A reference to a related issue in your repository (if applicable)

N/A

Checklist

  • I can confirm that my changes are working as intended

Copy link

@juliagallucci juliagallucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants