From 2a4692a74363d64d3c46a2c961b82e1628ff1bd0 Mon Sep 17 00:00:00 2001 From: yarishukla Date: Wed, 19 Aug 2026 21:04:34 -0400 Subject: [PATCH 1/3] complete assignment 1 --- assignment_1.ipynb | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 assignment_1.ipynb diff --git a/assignment_1.ipynb b/assignment_1.ipynb new file mode 100644 index 000000000..bc396c4ed --- /dev/null +++ b/assignment_1.ipynb @@ -0,0 +1,108 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "afed41dd", + "metadata": {}, + "outputs": [], + "source": [ + "def anagram_checker(word_a, word_b):\n", + " # Convert both words to lowercase\n", + " word_a = word_a.lower()\n", + " word_b = word_b.lower()\n", + "\n", + " # Sort the characters in each word\n", + " sorted_a = sorted(word_a)\n", + " sorted_b = sorted(word_b)\n", + "\n", + " # Compare the sorted words\n", + " return sorted_a == sorted_b" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "52bd0246", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"listen\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "bc603865", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"Night\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "b6bda758", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"Listen\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "python-env (3.11.15.final.0)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.15" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 19302d9856848eaeeb4ecb5fa4ad88961dabeed4 Mon Sep 17 00:00:00 2001 From: YariShukla <106463933+YariShukla@users.noreply.github.com> Date: Wed, 2 Sep 2026 09:38:04 -0400 Subject: [PATCH 2/3] Update assignment_1.ipynb --- assignment_1.ipynb | 108 ++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 69 deletions(-) diff --git a/assignment_1.ipynb b/assignment_1.ipynb index bc396c4ed..f746e2c49 100644 --- a/assignment_1.ipynb +++ b/assignment_1.ipynb @@ -1,108 +1,78 @@ { "cells": [ { - "cell_type": "code", - "execution_count": 2, - "id": "afed41dd", + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "def anagram_checker(word_a, word_b):\n", - " # Convert both words to lowercase\n", - " word_a = word_a.lower()\n", - " word_b = word_b.lower()\n", - "\n", - " # Sort the characters in each word\n", - " sorted_a = sorted(word_a)\n", - " sorted_b = sorted(word_b)\n", - "\n", - " # Compare the sorted words\n", - " return sorted_a == sorted_b" + "### Part 1: Building the base Anagram Checker" ] }, { "cell_type": "code", - "execution_count": 2, - "id": "52bd0246", + "execution_count": 1, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "True\n" + ] } ], "source": [ - "anagram_checker(\"Silent\", \"listen\")" + "def anagram_checker(word_a, word_b):\n", + " cleaned_word_a = word_a.lower()\n", + " cleaned_word_b = word_b.lower()\n", + " return sorted(cleaned_word_a) == sorted(cleaned_word_b)\n", + "\n", + "print(anagram_checker(\"Silent\", \"listen\"))\n", + "print(anagram_checker(\"Silent\", \"Night\"))\n", + "print(anagram_checker(\"night\", \"Thing\"))" ] }, { - "cell_type": "code", - "execution_count": 3, - "id": "bc603865", + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ - "anagram_checker(\"Silent\", \"Night\")" + "### Part 2: Expanding the functionality of the Anagram Checker" ] }, { "cell_type": "code", - "execution_count": 4, - "id": "b6bda758", + "execution_count": 2, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n" + ] } ], "source": [ - "anagram_checker(\"Silent\", \"Listen\")" + "def anagram_checker(word_a, word_b, is_case_sensitive=False):\n", + " if not is_case_sensitive:\n", + " word_a = word_a.lower()\n", + " word_b = word_b.lower()\n", + " return sorted(word_a) == sorted(word_b)\n", + "\n", + "print(anagram_checker(\"Silent\", \"listen\", False))\n", + "print(anagram_checker(\"Silent\", \"listen\", True))\n", + "print(anagram_checker(\"Silent\", \"Listen\", True))" ] } ], "metadata": { - "kernelspec": { - "display_name": "python-env (3.11.15.final.0)", - "language": "python", - "name": "python3" - }, "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.15" + "name": "python" } }, "nbformat": 4, - "nbformat_minor": 5 + "nbformat_minor": 2 } From 46fa8b8d86c4e8fe465a3bc4b3b7af71c387b405 Mon Sep 17 00:00:00 2001 From: YariShukla <106463933+YariShukla@users.noreply.github.com> Date: Wed, 2 Sep 2026 09:40:41 -0400 Subject: [PATCH 3/3] Update assignment_1.ipynb