From 50f938332bcf43142768f147b7c1ec520c6f3ebe Mon Sep 17 00:00:00 2001 From: anamaya Date: Tue, 11 Oct 2022 19:23:46 +0530 Subject: [PATCH 01/81] renamed A* -> A-Star --- hard/{A* => A-Star}/README.md | 0 hard/{A* => A-Star}/solution.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename hard/{A* => A-Star}/README.md (100%) rename hard/{A* => A-Star}/solution.py (100%) diff --git a/hard/A*/README.md b/hard/A-Star/README.md similarity index 100% rename from hard/A*/README.md rename to hard/A-Star/README.md diff --git a/hard/A*/solution.py b/hard/A-Star/solution.py similarity index 100% rename from hard/A*/solution.py rename to hard/A-Star/solution.py From 34eb5247d6b16349f1710e39473b017aa6f88251 Mon Sep 17 00:00:00 2001 From: anamaya Date: Tue, 11 Oct 2022 19:29:03 +0530 Subject: [PATCH 02/81] final commit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57da3bf..085a553 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ [![Open Source Love](https://firstcontributions.github.io/open-source-badges/badges/open-source-v1/open-source.svg)](https://github.com/GDSC-CEC) - Hacktoberfest is a month-long celebration of open source software run by DigitalOcean in partnership with GitHub and Twilio. Hacktoberfest is open to everyone in our global community! Four quality pull requests must be submitted to public GitHub repositories. You can sign up anytime between October 1 and October 31. +This repo is aimed at people who are new to open-source, earn and learn from that experience. + ### Goal of this repository There are many repositories on GitHub that contain a collection of algorithms and data structures in different programming languages. The goal of this repository is to provide a collection of algorithms and data structures in Python. Aim of this repository is to become a one-stop repository for all the algorithms and data structures in Python. Code should be well documented and easy to understand. The algorithms and data structures should be implemented according to the style guide mentioned below. @@ -32,7 +33,6 @@ Please read [CONTRIBUTING.md](/CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](/CODE_O ### Rules * There are total 70 problems open for contribution. -* Pull Requests are accepted on **First Come First Serve Basis**. * Once Pull Request is accepted on one problem, no other pull request will be reviewed on the that problem. Please try to contribute on other problem if any pull request is already merged. * Read the [CONTRIBUTING.md](/CONTRIBUTING.md) file. * Respect people. From c050b9ab47b03e4fb22131191cbf677087cf41a5 Mon Sep 17 00:00:00 2001 From: Manish Date: Tue, 11 Oct 2022 19:40:44 +0530 Subject: [PATCH 03/81] added linear search solution --- easy/linear_search/solution.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/easy/linear_search/solution.py b/easy/linear_search/solution.py index e69de29..e9dadd2 100644 --- a/easy/linear_search/solution.py +++ b/easy/linear_search/solution.py @@ -0,0 +1,7 @@ +def solution(array = [], item = -1): + if type(array) != list: + return -1 + for index, value in enumerate(array): + if value == item: + return index + return -1 From cb905d23878ff9db959d388cb3dc595a621947e0 Mon Sep 17 00:00:00 2001 From: anamaya Date: Tue, 11 Oct 2022 20:54:29 +0530 Subject: [PATCH 04/81] correction in testcases --- easy/quick_sort_recursion/tests.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/easy/quick_sort_recursion/tests.py b/easy/quick_sort_recursion/tests.py index d274e78..8770681 100644 --- a/easy/quick_sort_recursion/tests.py +++ b/easy/quick_sort_recursion/tests.py @@ -6,47 +6,43 @@ class Test(unittest.TestCase): """Quick Sort Test""" def test_bubble_sort_test_a(self): """Normal Test 1""" - self.assertEqual(solution([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5], "Test 1 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5], 0, 5), [1, 2, 3, 4, 5], "Test 1 Failed") def test_bubble_sort_test_b(self): """Normal Test 2""" - self.assertEqual(solution([5, 4, 3, 2, 1]), [1, 2, 3, 4, 5], "Test 2 Failed") + self.assertEqual(solution([5, 4, 3, 2, 1], 0, 5), [1, 2, 3, 4, 5], "Test 2 Failed") def test_bubble_sort_test_c(self): """Normal Test 3""" - self.assertEqual(solution([1, 3, 5, 2, 4]), [1, 2, 3, 4, 5], "Test 3 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4], 0, 5), [1, 2, 3, 4, 5], "Test 3 Failed") def test_bubble_sort_test_d(self): """Normal Test 4""" - self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7]), [1, 2, 3, 4, 5, 6, 7, 8], "Test 4 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7], 0, 5), [1, 2, 3, 4, 5, 6, 7, 8], "Test 4 Failed") def test_bubble_sort_test_e(self): """Normal Test 5""" - self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9]), [1, 2, 3, 4, 5, 6, 7, 8, 9], "Test 5 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9], 0, 9), [1, 2, 3, 4, 5, 6, 7, 8, 9], "Test 5 Failed") def test_bubble_sort_test_f(self): """Normal Test 6""" - self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9, 10]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 6 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9, 10], 0, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 6 Failed") def test_bubble_sort_test_g(self): """Normal Test 7""" - self.assertEqual(solution([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 7 Failed") + self.assertEqual(solution([10, 9, 8, 7, 6, 5, 4, 3, 2, 1], 0, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 7 Failed") def test_bubble_sort_test_h(self): """Exception Test 1""" - self.assertEqual(solution(["b", "c", "l", "a", "z"]), ["a", "b", "c", "l", "z"], "Test 8 Failed") + self.assertEqual(solution(["b", "c", "l", "a", "z"], 0, 5), ["a", "b", "c", "l", "z"], "Test 8 Failed") def test_bubble_sort_test_i(self): """Exception Test 2""" - self.assertEqual(solution(["b", "c", "l", "a", "z", "a", "b", "c", "l", "z"]), ["a", "a", "b", "b", "c", "c", "l", "l", "z", "z"], "Test 9 Failed") + self.assertEqual(solution(["b", "c", "l", "a", "z", "a", "b", "c", "l", "z"], 0, 10), ["a", "a", "b", "b", "c", "c", "l", "l", "z", "z"], "Test 9 Failed") def test_bubble_sort_test_j(self): """Exception Test 3""" - self.assertEqual(solution(), [], "Test 10 Failed") - - def test_bubble_sort_test_k(self): - """Exception Test 4""" - self.assertEqual(solution(1), [], "Test 11 Failed") + self.assertEqual(solution([], 0, 0), [], "Test 10 Failed") if __name__ == "__main__": From c7f82db20497301e680bc1b4132f628e799eb05d Mon Sep 17 00:00:00 2001 From: anamaya Date: Tue, 11 Oct 2022 21:22:39 +0530 Subject: [PATCH 05/81] correction in testcases --- easy/quick_sort_recursion/tests.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/easy/quick_sort_recursion/tests.py b/easy/quick_sort_recursion/tests.py index 8770681..d274e78 100644 --- a/easy/quick_sort_recursion/tests.py +++ b/easy/quick_sort_recursion/tests.py @@ -6,43 +6,47 @@ class Test(unittest.TestCase): """Quick Sort Test""" def test_bubble_sort_test_a(self): """Normal Test 1""" - self.assertEqual(solution([1, 2, 3, 4, 5], 0, 5), [1, 2, 3, 4, 5], "Test 1 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5], "Test 1 Failed") def test_bubble_sort_test_b(self): """Normal Test 2""" - self.assertEqual(solution([5, 4, 3, 2, 1], 0, 5), [1, 2, 3, 4, 5], "Test 2 Failed") + self.assertEqual(solution([5, 4, 3, 2, 1]), [1, 2, 3, 4, 5], "Test 2 Failed") def test_bubble_sort_test_c(self): """Normal Test 3""" - self.assertEqual(solution([1, 3, 5, 2, 4], 0, 5), [1, 2, 3, 4, 5], "Test 3 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4]), [1, 2, 3, 4, 5], "Test 3 Failed") def test_bubble_sort_test_d(self): """Normal Test 4""" - self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7], 0, 5), [1, 2, 3, 4, 5, 6, 7, 8], "Test 4 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7]), [1, 2, 3, 4, 5, 6, 7, 8], "Test 4 Failed") def test_bubble_sort_test_e(self): """Normal Test 5""" - self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9], 0, 9), [1, 2, 3, 4, 5, 6, 7, 8, 9], "Test 5 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9]), [1, 2, 3, 4, 5, 6, 7, 8, 9], "Test 5 Failed") def test_bubble_sort_test_f(self): """Normal Test 6""" - self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9, 10], 0, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 6 Failed") + self.assertEqual(solution([1, 3, 5, 2, 4, 6, 8, 7, 9, 10]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 6 Failed") def test_bubble_sort_test_g(self): """Normal Test 7""" - self.assertEqual(solution([10, 9, 8, 7, 6, 5, 4, 3, 2, 1], 0, 10), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 7 Failed") + self.assertEqual(solution([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "Test 7 Failed") def test_bubble_sort_test_h(self): """Exception Test 1""" - self.assertEqual(solution(["b", "c", "l", "a", "z"], 0, 5), ["a", "b", "c", "l", "z"], "Test 8 Failed") + self.assertEqual(solution(["b", "c", "l", "a", "z"]), ["a", "b", "c", "l", "z"], "Test 8 Failed") def test_bubble_sort_test_i(self): """Exception Test 2""" - self.assertEqual(solution(["b", "c", "l", "a", "z", "a", "b", "c", "l", "z"], 0, 10), ["a", "a", "b", "b", "c", "c", "l", "l", "z", "z"], "Test 9 Failed") + self.assertEqual(solution(["b", "c", "l", "a", "z", "a", "b", "c", "l", "z"]), ["a", "a", "b", "b", "c", "c", "l", "l", "z", "z"], "Test 9 Failed") def test_bubble_sort_test_j(self): """Exception Test 3""" - self.assertEqual(solution([], 0, 0), [], "Test 10 Failed") + self.assertEqual(solution(), [], "Test 10 Failed") + + def test_bubble_sort_test_k(self): + """Exception Test 4""" + self.assertEqual(solution(1), [], "Test 11 Failed") if __name__ == "__main__": From fa5c140f13daf8543eb0a1892afc3208bef92e21 Mon Sep 17 00:00:00 2001 From: anamaya Date: Tue, 11 Oct 2022 21:31:32 +0530 Subject: [PATCH 06/81] correction in testcases --- easy/quick_sort_recursion/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/quick_sort_recursion/tests.py b/easy/quick_sort_recursion/tests.py index d274e78..dbc8725 100644 --- a/easy/quick_sort_recursion/tests.py +++ b/easy/quick_sort_recursion/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() + utility.main() From e45c5145d14d93ae86946c3f0fdcb6418c130781 Mon Sep 17 00:00:00 2001 From: anamaya Date: Tue, 11 Oct 2022 21:33:52 +0530 Subject: [PATCH 07/81] correction in testcases --- easy/bubble_sort/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/bubble_sort/tests.py b/easy/bubble_sort/tests.py index 243341b..c98c3cb 100644 --- a/easy/bubble_sort/tests.py +++ b/easy/bubble_sort/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() \ No newline at end of file + utility.main() From ce1d544268316216da08e1478426d3bfc6241274 Mon Sep 17 00:00:00 2001 From: anamaya Date: Tue, 11 Oct 2022 21:40:17 +0530 Subject: [PATCH 08/81] correction in testcases --- easy/quick_sort/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/quick_sort/tests.py b/easy/quick_sort/tests.py index d274e78..dbc8725 100644 --- a/easy/quick_sort/tests.py +++ b/easy/quick_sort/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() + utility.main() From 3d661dc66490fc2b79a3f1d6a09ffd2708bb8062 Mon Sep 17 00:00:00 2001 From: Shailesh Date: Tue, 11 Oct 2022 21:46:04 +0530 Subject: [PATCH 09/81] added quicksort recursive solution --- easy/quick_sort_recursion/solution.py | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/easy/quick_sort_recursion/solution.py b/easy/quick_sort_recursion/solution.py index e69de29..a2f5a75 100644 --- a/easy/quick_sort_recursion/solution.py +++ b/easy/quick_sort_recursion/solution.py @@ -0,0 +1,33 @@ +def partition(array, low, high): + + pivot = array[high] + i = low - 1 + + for j in range(low, high): + if array[j] <= pivot: + + i = i + 1 + + (array[i], array[j]) = (array[j], array[i]) + + (array[i + 1], array[high]) = (array[high], array[i + 1]) + + return i + 1 + + +def quickSort(array, low, high): + if low < high: + + pi = partition(array, low, high) + + quickSort(array, low, pi - 1) + + quickSort(array, pi + 1, high) + + +def solution(arr=[]): + if type(arr) != list: + return[] + quickSort(arr,0,len(arr)-1) + return arr + From 272b5c8ef782fadc21114e1c290b3e2052ba79ce Mon Sep 17 00:00:00 2001 From: Shubham Bhardwaj Date: Thu, 13 Oct 2022 17:30:21 +0530 Subject: [PATCH 10/81] Fibonacci using recurion...all the test cases passed --- easy/fibonacci_recursion/solution.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/easy/fibonacci_recursion/solution.py b/easy/fibonacci_recursion/solution.py index 4d6454c..b31cae7 100644 --- a/easy/fibonacci_recursion/solution.py +++ b/easy/fibonacci_recursion/solution.py @@ -1,2 +1,7 @@ -def solution(): - pass +def answer(n): + if n<=1: + return n + else: + return answer(n-1)+answer(n-2) +n=int(input()) +print(answer(n)) From 6e3de12c1d93bf7ee04f16b906efa140ce269c07 Mon Sep 17 00:00:00 2001 From: Shantanu Rajput <90391285+neutralWire@users.noreply.github.com> Date: Thu, 13 Oct 2022 22:20:32 +0530 Subject: [PATCH 11/81] change in exception test 3 --- easy/right_angle_triangle_pattern/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/right_angle_triangle_pattern/tests.py b/easy/right_angle_triangle_pattern/tests.py index d0893e6..6728585 100644 --- a/easy/right_angle_triangle_pattern/tests.py +++ b/easy/right_angle_triangle_pattern/tests.py @@ -31,7 +31,7 @@ def test_half_diamond_f(self): def test_half_diamond_g(self): """Exception Test 3""" - self.assertEqual(solution(), -1, "Exception Test 3 Failed") + self.assertEqual(solution(-34), -1, "Exception Test 3 Failed") if __name__ == '__main__': - utility.main() \ No newline at end of file + utility.main() From 3daa2f5f4259a1dff73024635551b647be02de25 Mon Sep 17 00:00:00 2001 From: Ashutosh Rajput <115683263+ashurajpoot2003@users.noreply.github.com> Date: Thu, 13 Oct 2022 22:42:25 +0530 Subject: [PATCH 12/81] Solution of Right angle Triangle made a function named as solution which returns the pattern of a right angled triangle and if invalid input is entered then it returns -1 --- easy/right_angle_triangle_pattern/solution.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/easy/right_angle_triangle_pattern/solution.py b/easy/right_angle_triangle_pattern/solution.py index 4d6454c..54b249a 100644 --- a/easy/right_angle_triangle_pattern/solution.py +++ b/easy/right_angle_triangle_pattern/solution.py @@ -1,2 +1,12 @@ -def solution(): - pass +def solution(n): + if n<1: + return -1; + string= "" + if(n>0): + for row in range(n): + for column in range(row+1): + string+="*" + if row==n-1: + break + string+="\n" + return string From 2f34c0c056d9157a7ffdab0780394f79884ddd09 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:01:19 +0530 Subject: [PATCH 13/81] Correction in the README --- easy/fibonacci_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/fibonacci_recursion/README.md b/easy/fibonacci_recursion/README.md index caaa756..6025e24 100644 --- a/easy/fibonacci_recursion/README.md +++ b/easy/fibonacci_recursion/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and returns the nth Fibonacci number. #### Input Format -Create a function with name answer that takes an integer n as an argument and returns the nth Fibonacci number. +Create a function with name solution that takes an integer n as an argument and returns the nth Fibonacci number. #### Output Format Return a integer denoting the nth Fibonacci number. If invalid input is entered, return -1. @@ -47,4 +47,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 1cf93abb4b72f7c0815f01b364c4b136dd630397 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:36:41 +0530 Subject: [PATCH 14/81] corrections in readme --- easy/fibonacci_iterative/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/fibonacci_iterative/README.md b/easy/fibonacci_iterative/README.md index caaa756..6025e24 100644 --- a/easy/fibonacci_iterative/README.md +++ b/easy/fibonacci_iterative/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and returns the nth Fibonacci number. #### Input Format -Create a function with name answer that takes an integer n as an argument and returns the nth Fibonacci number. +Create a function with name solution that takes an integer n as an argument and returns the nth Fibonacci number. #### Output Format Return a integer denoting the nth Fibonacci number. If invalid input is entered, return -1. @@ -47,4 +47,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From aa814bca144e2d4ab0cf03e719fb56d6e6aff562 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:37:54 +0530 Subject: [PATCH 15/81] correction in readme. --- easy/binary_search_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/binary_search_recursion/README.md b/easy/binary_search_recursion/README.md index 0ba1e1b..91b0d08 100644 --- a/easy/binary_search_recursion/README.md +++ b/easy/binary_search_recursion/README.md @@ -5,7 +5,7 @@ Write a program to implement Binary Search in Python. ### Input Format -Create a function with name binary_search that takes a list and an integer as arguments and returns the index of the integer in the list if it exists, else return -1. If invalid input is entered, return -1. +Create a function with name solution that takes a list and an integer as arguments and returns the index of the integer in the list if it exists, else return -1. If invalid input is entered, return -1. ### Output Format Return an integer denoting the index of the integer in the list if it exists, else return -1. @@ -48,4 +48,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 4a8577d3d85a52223ff2574ba1735c6b8a49d4d3 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:38:21 +0530 Subject: [PATCH 16/81] Update README.md --- easy/binary_search/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/binary_search/README.md b/easy/binary_search/README.md index d75b0a7..9fb9fe8 100644 --- a/easy/binary_search/README.md +++ b/easy/binary_search/README.md @@ -5,7 +5,7 @@ Write a program to implement Binary Search in Python. ### Input Format -Create a function with name binary_search that takes a list and an integer as arguments and returns the index of the integer in the list if it exists, else return -1. If invalid input is entered, return -1. +Create a function with name solution that takes a list and an integer as arguments and returns the index of the integer in the list if it exists, else return -1. If invalid input is entered, return -1. ### Output Format Return an integer denoting the index of the integer in the list if it exists, else return -1. From 579f23a367194ce8db6bb71c285c3b1d8f2a3a7a Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:40:28 +0530 Subject: [PATCH 17/81] correction in readme --- easy/calculator/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/calculator/README.md b/easy/calculator/README.md index f183307..09845f9 100644 --- a/easy/calculator/README.md +++ b/easy/calculator/README.md @@ -5,7 +5,7 @@ Write a program to create a calculator in Python. ### Input Format -Create a function with name calculator that takes two numbers and an operator as arguments and returns the result of the operation. If invalid input is entered, return -1. +Create a function with name solution that takes two numbers and an operator as arguments and returns the result of the operation. If invalid input is entered, return -1. ### Output Format Return the result of the operation. @@ -51,4 +51,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 764929f7aa108f8b967aaf3e07971a9347a50570 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:41:00 +0530 Subject: [PATCH 18/81] Correction in readme --- easy/binary_to_decimal/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/binary_to_decimal/README.md b/easy/binary_to_decimal/README.md index 78cbfa4..b496a62 100644 --- a/easy/binary_to_decimal/README.md +++ b/easy/binary_to_decimal/README.md @@ -5,7 +5,7 @@ Write a program to convert a binary number to decimal in Python. ### Input Format -Create a function with name binary_to_decimal that takes a binary number as an argument and returns the decimal equivalent of the binary number. If invalid input is entered, return -1. +Create a function with name solution that takes a binary number as an argument and returns the decimal equivalent of the binary number. If invalid input is entered, return -1. ### Output Format Return an integer denoting the decimal equivalent of the binary number. @@ -47,4 +47,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From c2430595aa6e75d91f2938b695a7c74b365f4135 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:42:04 +0530 Subject: [PATCH 19/81] Correction in readme --- easy/bubble_sort/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/bubble_sort/README.md b/easy/bubble_sort/README.md index c66c0e0..d328c1a 100644 --- a/easy/bubble_sort/README.md +++ b/easy/bubble_sort/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Bubble Sort in Python. ### Input Format -Create a function with name bubble_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. @@ -46,4 +46,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From b5ac4cf3bd674f85905b6e8264d5db47436106e3 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:42:37 +0530 Subject: [PATCH 20/81] correction in readme --- easy/bubble_sort_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/bubble_sort_recursion/README.md b/easy/bubble_sort_recursion/README.md index c66c0e0..d328c1a 100644 --- a/easy/bubble_sort_recursion/README.md +++ b/easy/bubble_sort_recursion/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Bubble Sort in Python. ### Input Format -Create a function with name bubble_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. @@ -46,4 +46,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 0b7d2c42583b3bc0cac7cfed784333d7f59cd01f Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:43:14 +0530 Subject: [PATCH 21/81] correction in readme --- easy/decimal_to_binary/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/decimal_to_binary/README.md b/easy/decimal_to_binary/README.md index 866c48e..101872a 100644 --- a/easy/decimal_to_binary/README.md +++ b/easy/decimal_to_binary/README.md @@ -6,7 +6,7 @@ Write a function that takes a decimal number as an argument and returns the binary equivalent of that number. #### Input Format -Create a function with name answer that takes an integer n as an argument and returns the binary equivalent of that number. +Create a function with name solution that takes an integer n as an argument and returns the binary equivalent of that number. #### Output Format Return a integer denoting the binary equivalent of the decimal number. If invalid input is entered, return 0. @@ -47,4 +47,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 0bd2fb913d5c867db261b9964f7bb77a677089b6 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:44:40 +0530 Subject: [PATCH 22/81] correction in readme --- easy/diamond_pattern/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/easy/diamond_pattern/README.md b/easy/diamond_pattern/README.md index 66cac09..6a98c13 100644 --- a/easy/diamond_pattern/README.md +++ b/easy/diamond_pattern/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and prints a diamond pattern of height n. #### Input Format -Create a function with name answer that takes an integer n as an argument and prints a diamond pattern of height n. n should be an odd number and greater than 1. If n is even, return -1. +Create a function with name solution that takes an integer n as an argument and prints a diamond pattern of height n. n should be an odd number and greater than 1. If n is even, return -1. #### Output Format Print a diamond pattern of height n. If invalid input is entered, return -1. @@ -41,7 +41,7 @@ The diamond pattern of height 9 is: ***** *** * - ``` +``` - The first line contains 8 spaces and 1 star. - The second line contains 7 spaces and 3 stars. - The third line contains 6 spaces and 5 stars. @@ -77,4 +77,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From a7b62b3ab3d42ceaba4e813bf1b38adfa964bcb9 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:45:13 +0530 Subject: [PATCH 23/81] Correction in readme --- easy/factorial_iterative/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/factorial_iterative/README.md b/easy/factorial_iterative/README.md index d220f05..cc8725b 100644 --- a/easy/factorial_iterative/README.md +++ b/easy/factorial_iterative/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and returns the factorial of that number. #### Input Format -Create a function with name answer that takes an integer n as an argument and returns the factorial of that number. +Create a function with name solution that takes an integer n as an argument and returns the factorial of that number. #### Output Format Return a integer denoting the factorial of the number. If invalid input is entered, return -1. @@ -47,4 +47,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 763b0a15dbc8e140b709b474e96f1a3aee9f51a4 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:45:57 +0530 Subject: [PATCH 24/81] Correction in readme --- easy/factorial_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/factorial_recursion/README.md b/easy/factorial_recursion/README.md index d220f05..cc8725b 100644 --- a/easy/factorial_recursion/README.md +++ b/easy/factorial_recursion/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and returns the factorial of that number. #### Input Format -Create a function with name answer that takes an integer n as an argument and returns the factorial of that number. +Create a function with name solution that takes an integer n as an argument and returns the factorial of that number. #### Output Format Return a integer denoting the factorial of the number. If invalid input is entered, return -1. @@ -47,4 +47,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 52f57c78a91c9613510105f360fb1b4615bd365e Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:46:40 +0530 Subject: [PATCH 25/81] Correction in readme --- easy/half_diamond_pattern/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/half_diamond_pattern/README.md b/easy/half_diamond_pattern/README.md index 52e93ef..69eca0d 100644 --- a/easy/half_diamond_pattern/README.md +++ b/easy/half_diamond_pattern/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and prints a half diamond star pattern of height n. #### Input Format -Create a function with name answer that takes an integer n as an argument and prints a half diamond star pattern of height n. n should be odd and greater than 1. +Create a function with name solution that takes an integer n as an argument and prints a half diamond star pattern of height n. n should be odd and greater than 1. #### Output Format Print a half diamond star pattern of height n. If invalid input is entered, return -1. @@ -55,4 +55,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From d846aaf18c8544da21c67b58c89581376d5a096b Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:47:07 +0530 Subject: [PATCH 26/81] Correction in readme --- easy/half_pyramid_pattern/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/half_pyramid_pattern/README.md b/easy/half_pyramid_pattern/README.md index 5b46d24..bb9f7f2 100644 --- a/easy/half_pyramid_pattern/README.md +++ b/easy/half_pyramid_pattern/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and prints a half pyramid star pattern of height n. #### Input Format -Create a function with name answer that takes an integer n as an argument and prints a half pyramid star pattern of height n. +Create a function with name solution that takes an integer n as an argument and prints a half pyramid star pattern of height n. #### Output Format Print a half pyramid star pattern of height n. If invalid input is entered, return -1. @@ -51,4 +51,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 058c5410514e6f8696e95be24f63a2788ec3c9ec Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:47:53 +0530 Subject: [PATCH 27/81] Correction in readme --- easy/hourglass_pattern/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/hourglass_pattern/README.md b/easy/hourglass_pattern/README.md index 49bb039..0e04215 100644 --- a/easy/hourglass_pattern/README.md +++ b/easy/hourglass_pattern/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and prints an hourglass star pattern of height n. #### Input Format -Create a function with name answer that takes an integer n as an argument and prints an hourglass star pattern of height n. n should be odd and greater than 1. +Create a function with name solution that takes an integer n as an argument and prints an hourglass star pattern of height n. n should be odd and greater than 1. #### Output Format Print an hourglass star pattern of height n. If invalid input is entered, return -1. @@ -51,4 +51,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 957218410648475f510eab3c3479596cba03c575 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:48:22 +0530 Subject: [PATCH 28/81] Correction in readme --- easy/insertion_sort/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/insertion_sort/README.md b/easy/insertion_sort/README.md index ffe71dc..cdd1012 100644 --- a/easy/insertion_sort/README.md +++ b/easy/insertion_sort/README.md @@ -6,7 +6,7 @@ Write a function that takes a list as an argument and sorts it using the insertion sort algorithm. #### Input Format -Create a function with name answer that takes a list as an argument and sorts it using the insertion sort algorithm. +Create a function with name solution that takes a list as an argument and sorts it using the insertion sort algorithm. #### Output Format Return the sorted list. If invalid input is entered, return []. @@ -48,4 +48,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From b85ae29381a95ecb57d21a57d40f6c90e1559213 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:49:13 +0530 Subject: [PATCH 29/81] Correction in readme --- easy/insertion_sort_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/insertion_sort_recursion/README.md b/easy/insertion_sort_recursion/README.md index ffe71dc..cdd1012 100644 --- a/easy/insertion_sort_recursion/README.md +++ b/easy/insertion_sort_recursion/README.md @@ -6,7 +6,7 @@ Write a function that takes a list as an argument and sorts it using the insertion sort algorithm. #### Input Format -Create a function with name answer that takes a list as an argument and sorts it using the insertion sort algorithm. +Create a function with name solution that takes a list as an argument and sorts it using the insertion sort algorithm. #### Output Format Return the sorted list. If invalid input is entered, return []. @@ -48,4 +48,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 7900320da40c1c616fc5ab9fd00bb2f333f0caea Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:49:53 +0530 Subject: [PATCH 30/81] Correction in readme --- easy/inverted_right_angle_triangle_pattern/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/inverted_right_angle_triangle_pattern/README.md b/easy/inverted_right_angle_triangle_pattern/README.md index 0d48ded..4ffce2d 100644 --- a/easy/inverted_right_angle_triangle_pattern/README.md +++ b/easy/inverted_right_angle_triangle_pattern/README.md @@ -5,8 +5,8 @@ #### Problem Statement Write a function that takes a number n as an argument and prints a inverted right angled star pattern of height n. -#### Input Format -Create a function with name answer that takes an integer n as an argument and prints a inverted right angled star pattern of height n. +#### Input Forman +Create a function with name solution that takes an integer n as an argument and prints a inverted right angled star pattern of height n. #### Output Format Print a inverted right angled star pattern of height n. If invalid input is entered, return -1. From c29d0f6733fcf2603b68c15ab674f6698a82df74 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:50:40 +0530 Subject: [PATCH 31/81] Correction in readme --- easy/inverted_half_pyramid_pattern/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/inverted_half_pyramid_pattern/README.md b/easy/inverted_half_pyramid_pattern/README.md index 8332e65..9ea919f 100644 --- a/easy/inverted_half_pyramid_pattern/README.md +++ b/easy/inverted_half_pyramid_pattern/README.md @@ -5,8 +5,8 @@ #### Problem Statement Write a function that takes a number n as an argument and prints a inverted half pyramid star pattern of height n. -#### Input Format -Create a function with name answer that takes an integer n as an argument and prints a half pyramid star pattern of height n. +#### Input Format +Create a function with name solution that takes an integer n as an argument and prints a half pyramid star pattern of height n. #### Output Format Print a inverted half pyramid star pattern of height n. If invalid input is entered, return -1. From 874adbaef8711073c4fdcad9354cdadb0b9ca1ed Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:51:15 +0530 Subject: [PATCH 32/81] Correction in readme --- .../inverted_right_angle_triangle_pattern_with_number/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/inverted_right_angle_triangle_pattern_with_number/README.md b/easy/inverted_right_angle_triangle_pattern_with_number/README.md index 6ca64b6..4c49880 100644 --- a/easy/inverted_right_angle_triangle_pattern_with_number/README.md +++ b/easy/inverted_right_angle_triangle_pattern_with_number/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and prints a inverted right angle triangle pattern with number of height n. #### Input Format -Create a function with name answer that takes an integer n as an argument and prints a inverted right angle pattern star pattern with number of height n. +Create a function with name solution that takes an integer n as an argument and prints a inverted right angle pattern star pattern with number of height n. #### Output Format Print a inverted right angle triangle star pattern wuth number of height n. If invalid input is entered, return -1. From 52201a05e0b71fb275c7642de7d6a70978d39063 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:52:21 +0530 Subject: [PATCH 33/81] Correction in readme --- easy/linear_search_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/linear_search_recursion/README.md b/easy/linear_search_recursion/README.md index 7e72d70..ed78a3c 100644 --- a/easy/linear_search_recursion/README.md +++ b/easy/linear_search_recursion/README.md @@ -4,8 +4,8 @@ ### Problem Statement Write a program to implement Linear Search in Python. -### Input Format -Create a function with name linear_search that takes a list and an integer as arguments and returns the index of the integer in the list if it exists, else return -1. If invalid input is entered, return -1. +### Input Format +Create a function with name solution that takes a list and an integer as arguments and returns the index of the integer in the list if it exists, else return -1. If invalid input is entered, return -1. ### Output Format Return an integer denoting the index of the integer in the list if it exists, else return -1. From 439d6a7e79d96aff7badb182a735637747a7defb Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:52:54 +0530 Subject: [PATCH 34/81] Correction in readme --- easy/merge_sort/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/merge_sort/README.md b/easy/merge_sort/README.md index b403b96..db829dc 100644 --- a/easy/merge_sort/README.md +++ b/easy/merge_sort/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Merge Sort in Python. ### Input Format -Create a function with name merge_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. From 8dd8d260430811d48476e8b783d1c2cc97743358 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:53:35 +0530 Subject: [PATCH 35/81] Correction in readme --- easy/merge_sort_recursion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/merge_sort_recursion/README.md b/easy/merge_sort_recursion/README.md index b403b96..db829dc 100644 --- a/easy/merge_sort_recursion/README.md +++ b/easy/merge_sort_recursion/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Merge Sort in Python. ### Input Format -Create a function with name merge_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. From 9097e9c029fedb432a3175ff1cf150ac9f72295f Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:54:54 +0530 Subject: [PATCH 36/81] correction in readme --- easy/palindrome_iterative/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/palindrome_iterative/README.md b/easy/palindrome_iterative/README.md index 12d15c7..f71bddc 100644 --- a/easy/palindrome_iterative/README.md +++ b/easy/palindrome_iterative/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and returns whether the number is plaindrome or not in 0 or 1 (0-Not a plindrome, 1-Plaindrome). #### Input Format -Create a function with name answer that takes an integer n as an argument and returns 0 or 1. +Create a function with name solution that takes an integer n as an argument and returns 0 or 1. #### Output Format Returns an integer i.e, 0 or 1. If invalid input is entered, return -1. From e27af09bf66dacd0d0735cc5359245b8fe3e092b Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:55:28 +0530 Subject: [PATCH 37/81] Correction in readme --- easy/palindrome_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/palindrome_recursion/README.md b/easy/palindrome_recursion/README.md index 6788777..4e3102c 100644 --- a/easy/palindrome_recursion/README.md +++ b/easy/palindrome_recursion/README.md @@ -5,8 +5,8 @@ #### Problem Statement Write a function that takes a number n as an argument and returns whther the number is plaindrome or not in 0 or 1 (0-Not a plindrome, 1-Plaindrome). -#### Input Format -Create a function with name answer that takes an integer n as an argument and returns 0 or 1. +#### Input Format +Create a function with name solution that takes an integer n as an argument and returns 0 or 1. #### Output Format Returns an integer i.e, 0 or 1. If invalid input is entered, return -1. From 139d48d13cf236133fc6c3e55ef3ae5998d03ee8 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:56:56 +0530 Subject: [PATCH 38/81] Correction in readme --- easy/prime_iterative/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/prime_iterative/README.md b/easy/prime_iterative/README.md index 8b8b4fd..59a67da 100644 --- a/easy/prime_iterative/README.md +++ b/easy/prime_iterative/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and returns whether the number is prime or not in 0 or 1 (0-Not a plindrome, 1-Plaindrome). #### Input Format -Create a function with name answer that takes an integer n as an argument and returns 0 or 1. +Create a function with name solution that takes an integer n as an argument and returns 0 or 1. #### Output Format Returns an integer i.e, 0 or 1. If invalid input is entered, return -1. From d6ba4af21affc4ebd0341d93f9e6114cb44c5940 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:57:27 +0530 Subject: [PATCH 39/81] Correction in readme --- easy/prime_recursion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/prime_recursion/README.md b/easy/prime_recursion/README.md index 8b8b4fd..59a67da 100644 --- a/easy/prime_recursion/README.md +++ b/easy/prime_recursion/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and returns whether the number is prime or not in 0 or 1 (0-Not a plindrome, 1-Plaindrome). #### Input Format -Create a function with name answer that takes an integer n as an argument and returns 0 or 1. +Create a function with name solution that takes an integer n as an argument and returns 0 or 1. #### Output Format Returns an integer i.e, 0 or 1. If invalid input is entered, return -1. From 4e0cd3935bffa4919317b9a7b5b1ee39d6e054a8 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:58:12 +0530 Subject: [PATCH 40/81] Correction in readme --- easy/quick_sort_recursion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/quick_sort_recursion/README.md b/easy/quick_sort_recursion/README.md index 660d556..72efd1d 100644 --- a/easy/quick_sort_recursion/README.md +++ b/easy/quick_sort_recursion/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Quick Sort in Python. ### Input Format -Create a function with name quick_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. From acc42a03e4a49a41000153b4d2c1e223755ab9f3 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:58:48 +0530 Subject: [PATCH 41/81] Correction in readme --- easy/quick_sort/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/quick_sort/README.md b/easy/quick_sort/README.md index 660d556..72efd1d 100644 --- a/easy/quick_sort/README.md +++ b/easy/quick_sort/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Quick Sort in Python. ### Input Format -Create a function with name quick_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. From 7d71023f2e1674830380e7247c64de4b41767914 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:59:17 +0530 Subject: [PATCH 42/81] Correction in readme --- easy/right_angle_triangle_pattern/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/right_angle_triangle_pattern/README.md b/easy/right_angle_triangle_pattern/README.md index 2149108..5b35fc8 100644 --- a/easy/right_angle_triangle_pattern/README.md +++ b/easy/right_angle_triangle_pattern/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and prints a right angle triangle pattern of height n. #### Input Format -Create a function with name answer that takes an integer n as an argument and prints a right angle triangle star pattern of height n. +Create a function with name solution that takes an integer n as an argument and prints a right angle triangle star pattern of height n. #### Output Format Print a right angle triangle star pattern of height n. If invalid input is entered, return -1. From bb979c9a5a6a78166fc49ba2df63a17b28b9fcee Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:59:52 +0530 Subject: [PATCH 43/81] Correction in readme --- easy/right_angle_triangle_pattern_with_number/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/right_angle_triangle_pattern_with_number/README.md b/easy/right_angle_triangle_pattern_with_number/README.md index d1b5fce..abb912f 100644 --- a/easy/right_angle_triangle_pattern_with_number/README.md +++ b/easy/right_angle_triangle_pattern_with_number/README.md @@ -6,7 +6,7 @@ Write a function that takes a number n as an argument and prints a right angle triangle with number pattern of height n. #### Input Format -Create a function with name answer that takes an integer n as an argument and prints a right angle triangle with number pattern of height n. +Create a function with name solution that takes an integer n as an argument and prints a right angle triangle with number pattern of height n. #### Output Format Print a right angle triangle with number pattern of height n. If invalid input is entered, return -1. From 9f902f2f77d0e1577746e26388de07058ab2a455 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:00:43 +0530 Subject: [PATCH 44/81] Correction in readme --- easy/selection_sort/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/selection_sort/README.md b/easy/selection_sort/README.md index 63755c3..771b210 100644 --- a/easy/selection_sort/README.md +++ b/easy/selection_sort/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Selection Sort in Python. ### Input Format -Create a function with name merge_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. From bc2ebae5ca98509b4849fc659d476a91753b8b9d Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:01:12 +0530 Subject: [PATCH 45/81] Correction in readme --- easy/selection_sort_recursion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/selection_sort_recursion/README.md b/easy/selection_sort_recursion/README.md index 63755c3..771b210 100644 --- a/easy/selection_sort_recursion/README.md +++ b/easy/selection_sort_recursion/README.md @@ -5,7 +5,7 @@ Write a program to sort a list of numbers in ascending order using Selection Sort in Python. ### Input Format -Create a function with name merge_sort that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. +Create a function with name solution that takes a list of numbers as an argument and returns the sorted list of numbers. If invalid input is entered, return empty list. ### Output Format Return a list of numbers in ascending order. From 1bc6b571fedb4dd28af429e279de450d75278ca8 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:01:38 +0530 Subject: [PATCH 46/81] Correction in readme --- easy/sum_of_digits/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/sum_of_digits/README.md b/easy/sum_of_digits/README.md index f689223..04587e3 100644 --- a/easy/sum_of_digits/README.md +++ b/easy/sum_of_digits/README.md @@ -5,7 +5,7 @@ Write a program to calculate sum of digits in Python. ### Input Format -Create a function with name sum that takes a number and returns the sum of the digits. If invalid input is entered, return -1. +Create a function with name solution that takes a number and returns the sum of the digits. If invalid input is entered, return -1. ### Output Format Return the sum of digits. Else if input is invalid then return -1. From 92891b02fc256d6bde18b54131444cdc76fb26f8 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:02:14 +0530 Subject: [PATCH 47/81] Correction in readme --- easy/sum_of_digits_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/sum_of_digits_recursion/README.md b/easy/sum_of_digits_recursion/README.md index f689223..e58a4af 100644 --- a/easy/sum_of_digits_recursion/README.md +++ b/easy/sum_of_digits_recursion/README.md @@ -1,11 +1,11 @@ -#Hacktoberfest 2022 +# Hacktoberfest 2022 ## Sum Of Digits in Python ### Problem Statement Write a program to calculate sum of digits in Python. ### Input Format -Create a function with name sum that takes a number and returns the sum of the digits. If invalid input is entered, return -1. +Create a function with name solution that takes a number and returns the sum of the digits. If invalid input is entered, return -1. ### Output Format Return the sum of digits. Else if input is invalid then return -1. From 0f50b65318150c74e38b34c45d510bc2175e8d60 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:02:58 +0530 Subject: [PATCH 48/81] Correction in readme --- easy/sum_of_n_numbers/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/sum_of_n_numbers/README.md b/easy/sum_of_n_numbers/README.md index ce92a3f..d9d1802 100644 --- a/easy/sum_of_n_numbers/README.md +++ b/easy/sum_of_n_numbers/README.md @@ -1,11 +1,11 @@ -#Hacktoberfest 2022 +# Hacktoberfest 2022 ## Sum Of N Natural Numbers in Python ### Problem Statement Write a program to calculate sum of n natural numbers in Python. ### Input Format -Create a function with name sum that takes a number upto which the sum is required and returns the sum of the numbers. If invalid input is entered, return -1. +Create a function with name solution that takes a number upto which the sum is required and returns the sum of the numbers. If invalid input is entered, return -1. ### Output Format Returns the sum. Else if input is invalid then return -1. From c4655bb6620f5b02237477c769fb97dce2ebdce1 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:03:36 +0530 Subject: [PATCH 49/81] Correction in tests --- easy/sum_of_n_numbers/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/sum_of_n_numbers/tests.py b/easy/sum_of_n_numbers/tests.py index 659d0a6..aa8cb5a 100644 --- a/easy/sum_of_n_numbers/tests.py +++ b/easy/sum_of_n_numbers/tests.py @@ -37,4 +37,4 @@ def test_calculator_test_h(self): self.assertEqual(solution(-123), -1, "Test 8 Failed") if __name__ == "__main__": - unittest.main() + utility.main() From 44cffd9d2d7db49f9ded12c937c381c98191ceb8 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:04:34 +0530 Subject: [PATCH 50/81] Correction in tests --- easy/sum_of_n_numbers_recursion/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/sum_of_n_numbers_recursion/tests.py b/easy/sum_of_n_numbers_recursion/tests.py index 659d0a6..aa8cb5a 100644 --- a/easy/sum_of_n_numbers_recursion/tests.py +++ b/easy/sum_of_n_numbers_recursion/tests.py @@ -37,4 +37,4 @@ def test_calculator_test_h(self): self.assertEqual(solution(-123), -1, "Test 8 Failed") if __name__ == "__main__": - unittest.main() + utility.main() From a1d84a9c1b74e961293119a24cef2e9d9e7284b6 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:04:55 +0530 Subject: [PATCH 51/81] Correction in readme --- easy/sum_of_n_numbers_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/sum_of_n_numbers_recursion/README.md b/easy/sum_of_n_numbers_recursion/README.md index ce92a3f..d9d1802 100644 --- a/easy/sum_of_n_numbers_recursion/README.md +++ b/easy/sum_of_n_numbers_recursion/README.md @@ -1,11 +1,11 @@ -#Hacktoberfest 2022 +# Hacktoberfest 2022 ## Sum Of N Natural Numbers in Python ### Problem Statement Write a program to calculate sum of n natural numbers in Python. ### Input Format -Create a function with name sum that takes a number upto which the sum is required and returns the sum of the numbers. If invalid input is entered, return -1. +Create a function with name solution that takes a number upto which the sum is required and returns the sum of the numbers. If invalid input is entered, return -1. ### Output Format Returns the sum. Else if input is invalid then return -1. From 6fdd9f60191a681c55065b5a27daf6284471fbed Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:05:41 +0530 Subject: [PATCH 52/81] Correction in readme --- easy/tower_of_hanoi/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/tower_of_hanoi/README.md b/easy/tower_of_hanoi/README.md index de5ef75..c0d0c32 100644 --- a/easy/tower_of_hanoi/README.md +++ b/easy/tower_of_hanoi/README.md @@ -6,7 +6,7 @@ The Tower of Hanoi is a mathematical puzzle where we have three rods and n disks 2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack. 3. No disk may be placed on top of a smaller disk. #### Input Format -Create a function with name answer that takes an integer n as an argument and returns the minimum number of moves required to solve the Tower of Hanoi puzzle. +Create a function with name solution that takes an integer n as an argument and returns the minimum number of moves required to solve the Tower of Hanoi puzzle. #### Output Format Return an integer denoting the minimum number of moves required to solve the Tower of Hanoi puzzle. If invalid input is entered, return 0. #### Sample Input @@ -52,4 +52,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 4b7d0af81c47557bfb326181ddf9e6768a81ccb7 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:06:12 +0530 Subject: [PATCH 53/81] Correction in readme --- easy/tower_of_hanoi_recursion/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/tower_of_hanoi_recursion/README.md b/easy/tower_of_hanoi_recursion/README.md index de5ef75..c0d0c32 100644 --- a/easy/tower_of_hanoi_recursion/README.md +++ b/easy/tower_of_hanoi_recursion/README.md @@ -6,7 +6,7 @@ The Tower of Hanoi is a mathematical puzzle where we have three rods and n disks 2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack. 3. No disk may be placed on top of a smaller disk. #### Input Format -Create a function with name answer that takes an integer n as an argument and returns the minimum number of moves required to solve the Tower of Hanoi puzzle. +Create a function with name solution that takes an integer n as an argument and returns the minimum number of moves required to solve the Tower of Hanoi puzzle. #### Output Format Return an integer denoting the minimum number of moves required to solve the Tower of Hanoi puzzle. If invalid input is entered, return 0. #### Sample Input @@ -52,4 +52,4 @@ If all test cases pass, your solution will be merged with the main branch. If yo ## License **This project is licensed under the GNU GENERAL PUBLIC License - see the [LICENSE](../../LICENSE) file for details** -## Happy Coding! :smile: \ No newline at end of file +## Happy Coding! :smile: From 5e8697fee4e2962692c1ea0cff78cf10b2a704fa Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:06:57 +0530 Subject: [PATCH 54/81] Correction in tests --- easy/merge_sort_recursion/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/merge_sort_recursion/tests.py b/easy/merge_sort_recursion/tests.py index e5af977..4468fdb 100644 --- a/easy/merge_sort_recursion/tests.py +++ b/easy/merge_sort_recursion/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() + utility.main() From 890c1c9be08cf8d7e820d5bc00128e34b71153d6 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:07:27 +0530 Subject: [PATCH 55/81] Correction in tests --- easy/merge_sort/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/merge_sort/tests.py b/easy/merge_sort/tests.py index 47d839c..0ef5631 100644 --- a/easy/merge_sort/tests.py +++ b/easy/merge_sort/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() + utility.main() From 72c40cdbd3f2f56d50051ee9e6d2c7152f2a5bc2 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:08:00 +0530 Subject: [PATCH 56/81] Correction in tests --- easy/bubble_sort_recursion/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/bubble_sort_recursion/tests.py b/easy/bubble_sort_recursion/tests.py index 243341b..c98c3cb 100644 --- a/easy/bubble_sort_recursion/tests.py +++ b/easy/bubble_sort_recursion/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() \ No newline at end of file + utility.main() From c902bc58ea80879549187b50ddad550ae41eddb3 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:08:52 +0530 Subject: [PATCH 57/81] Correction in tests --- easy/selection_sort/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/selection_sort/tests.py b/easy/selection_sort/tests.py index d274e78..dbc8725 100644 --- a/easy/selection_sort/tests.py +++ b/easy/selection_sort/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() + utility.main() From 9f3ec54347e1b94f0ff05d2f6505910f63b91703 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:09:23 +0530 Subject: [PATCH 58/81] Correction in tests --- easy/selection_sort_recursion/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/selection_sort_recursion/tests.py b/easy/selection_sort_recursion/tests.py index d274e78..dbc8725 100644 --- a/easy/selection_sort_recursion/tests.py +++ b/easy/selection_sort_recursion/tests.py @@ -50,4 +50,4 @@ def test_bubble_sort_test_k(self): if __name__ == "__main__": - unittest.main() + utility.main() From 4c49e5eba3cfef52960298602687c949c5fc513d Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:10:09 +0530 Subject: [PATCH 59/81] Correction in tests --- easy/calculator/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/calculator/tests.py b/easy/calculator/tests.py index ea525d3..c12b658 100644 --- a/easy/calculator/tests.py +++ b/easy/calculator/tests.py @@ -37,4 +37,4 @@ def test_calculator_test_h(self): self.assertEqual(solution(1, 1), -1, "Test 8 Failed") if __name__ == "__main__": - unittest.main() \ No newline at end of file + utility.main() From 17ae8f0d21ce411fc837b33d69219997a5c3f892 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:10:53 +0530 Subject: [PATCH 60/81] Correction in tests --- easy/binary_to_decimal/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/binary_to_decimal/tests.py b/easy/binary_to_decimal/tests.py index e8d3628..a9aa78e 100644 --- a/easy/binary_to_decimal/tests.py +++ b/easy/binary_to_decimal/tests.py @@ -46,4 +46,4 @@ def test_binary_to_decimal_test_j(self): if __name__ == "__main__": - unittest.main() \ No newline at end of file + utility.main() From 016385d109518d71e2d615e824f02b29b4e217c3 Mon Sep 17 00:00:00 2001 From: infernus01stronger <115586269+infernus01stronger@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:12:14 +0530 Subject: [PATCH 61/81] update solution.py --- easy/fibonacci_recursion/solution.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/easy/fibonacci_recursion/solution.py b/easy/fibonacci_recursion/solution.py index b31cae7..d2ae861 100644 --- a/easy/fibonacci_recursion/solution.py +++ b/easy/fibonacci_recursion/solution.py @@ -1,7 +1,7 @@ -def answer(n): - if n<=1: - return n - else: - return answer(n-1)+answer(n-2) -n=int(input()) -print(answer(n)) +def solution(*args): + if len(args)==0: + return -1 + + if args[0]<=1: + return args[0] + return solution(args[0]-1)+solution(args[0]-2) From 4ea5b95727d8865a74ffa31133cf7a096f4aa026 Mon Sep 17 00:00:00 2001 From: Shubhang <90391327+Shubhang-2111@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:50:54 +0530 Subject: [PATCH 62/81] Update solution.py Created function sum of digits --- easy/sum_of_digits/solution.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/easy/sum_of_digits/solution.py b/easy/sum_of_digits/solution.py index e69de29..8bc3239 100644 --- a/easy/sum_of_digits/solution.py +++ b/easy/sum_of_digits/solution.py @@ -0,0 +1,16 @@ +def solution(n): + if not str(n).isnumeric(): + return -1 + + if int(n) == 0: + return 0 + + if int(n)<0: + return -1 + + sum = 0 + for digit in str(n): + sum += int(digit) + return sum + + From 8586e0e2810c810da663261a02acbf08ad95e35b Mon Sep 17 00:00:00 2001 From: Shubhang <90391327+Shubhang-2111@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:51:59 +0530 Subject: [PATCH 63/81] Delete solution.py --- easy/sum_of_digits/solution.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 easy/sum_of_digits/solution.py diff --git a/easy/sum_of_digits/solution.py b/easy/sum_of_digits/solution.py deleted file mode 100644 index 8bc3239..0000000 --- a/easy/sum_of_digits/solution.py +++ /dev/null @@ -1,16 +0,0 @@ -def solution(n): - if not str(n).isnumeric(): - return -1 - - if int(n) == 0: - return 0 - - if int(n)<0: - return -1 - - sum = 0 - for digit in str(n): - sum += int(digit) - return sum - - From a5b6db9368a78d24cbe7b48a2e1312d0587e4263 Mon Sep 17 00:00:00 2001 From: Shubhang <90391327+Shubhang-2111@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:52:14 +0530 Subject: [PATCH 64/81] Create solution.py --- easy/sum_of_digits/solution.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 easy/sum_of_digits/solution.py diff --git a/easy/sum_of_digits/solution.py b/easy/sum_of_digits/solution.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/easy/sum_of_digits/solution.py @@ -0,0 +1 @@ + From 97c893315479bdc741a604f7b16746f8ec90a934 Mon Sep 17 00:00:00 2001 From: Shubhang-2111 Date: Fri, 14 Oct 2022 11:17:04 +0530 Subject: [PATCH 65/81] added sum of digits solution --- easy/sum_of_digits/solution.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/easy/sum_of_digits/solution.py b/easy/sum_of_digits/solution.py index e69de29..7dedf55 100644 --- a/easy/sum_of_digits/solution.py +++ b/easy/sum_of_digits/solution.py @@ -0,0 +1,16 @@ +def solution(n): + if not str(n).isnumeric(): + return -1 + + if int(n) == 0: + return 0 + + if int(n)<0: + return -1 + + sum = 0 + for digit in str(n): + sum += int(digit) + return sum + + From d25bb942852c2a98f93c7f9ae267a853383e0d0f Mon Sep 17 00:00:00 2001 From: Saksham Sharma <89659787+SakshamSharma07@users.noreply.github.com> Date: Fri, 14 Oct 2022 13:10:28 +0530 Subject: [PATCH 66/81] recursive binary search this program recursively search an element in a list --- easy/binary_search_recursion/solution.py | 41 ++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/easy/binary_search_recursion/solution.py b/easy/binary_search_recursion/solution.py index 4d6454c..f43e4cf 100644 --- a/easy/binary_search_recursion/solution.py +++ b/easy/binary_search_recursion/solution.py @@ -1,2 +1,39 @@ -def solution(): - pass +# Python3 Program for recursive binary search. +def solution(arr, l, r, x): + + # Check base case + if r >= l: + + mid = l + (r - l) // 2 + + # If element is present at the middle itself + if arr[mid] == x: + return mid + + # If element is smaller than mid, then it + # can only be present in left subarray + elif arr[mid] > x: + return solution(arr, l, mid-1, x) + + # Else the element can only be present + # in right subarray + else: + return solution(arr, mid + 1, r, x) + + else: + # Element is not present in the array + return -1 + + +# Driver Code +arr = [2, 3, 4, 10, 40] +x = 10 + +# Function call +result = solution(arr, 0, len(arr)-1, x) + +if result != -1: + print("Element is present at index % d" % result) +else: + print("Element is not present in array") + From 256f129317b59914db930a236bb314a74935fec0 Mon Sep 17 00:00:00 2001 From: Saksham Sharma <89659787+SakshamSharma07@users.noreply.github.com> Date: Fri, 14 Oct 2022 13:47:08 +0530 Subject: [PATCH 67/81] update test.py code have been updated --- easy/binary_search_recursion/tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/easy/binary_search_recursion/tests.py b/easy/binary_search_recursion/tests.py index 36f262c..72dfabf 100644 --- a/easy/binary_search_recursion/tests.py +++ b/easy/binary_search_recursion/tests.py @@ -6,23 +6,23 @@ class Test(unittest.TestCase): "Binary Search Test" def test_binary_search_test_a(self): "Normal Test 1" - self.assertEqual(solution([1, 2, 3, 4, 5], 3), 2, "Test 1 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 3), 2, "Test 1 Failed") def test_binary_search_test_b(self): "Normal Test 2" - self.assertEqual(solution([1, 2, 3, 4, 5], 5), 4, "Test 2 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 5), 4, "Test 2 Failed") def test_binary_search_test_c(self): "Normal Test 3" - self.assertEqual(solution([1, 2, 3, 4, 5], 1), 0, "Test 3 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 1), 0, "Test 3 Failed") def test_binary_search_test_d(self): "Normal Test 4" - self.assertEqual(solution([1, 2, 3, 4, 5], 0), -1, "Test 4 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 0), -1, "Test 4 Failed") def test_binary_search_test_e(self): "Normal Test 5" - self.assertEqual(solution([1, 2, 3, 4, 5], 6), -1, "Test 5 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 6), -1, "Test 5 Failed") def test_binary_search_test_i(self): "Exception Test 1" @@ -42,4 +42,4 @@ def test_binary_search_test_l(self): if __name__ == "__main__": - utility.main() \ No newline at end of file + utility.main() From e3bf76aa46a91022a149164a0a0ff5af49079620 Mon Sep 17 00:00:00 2001 From: aicx Date: Fri, 14 Oct 2022 23:49:27 +0200 Subject: [PATCH 68/81] bubble_sort_recursion implementation. --- easy/bubble_sort_recursion/solution.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/easy/bubble_sort_recursion/solution.py b/easy/bubble_sort_recursion/solution.py index 4d6454c..252207e 100644 --- a/easy/bubble_sort_recursion/solution.py +++ b/easy/bubble_sort_recursion/solution.py @@ -1,2 +1,23 @@ -def solution(): - pass +def solution(list_of_nums = []): + return bubble_sort(list_of_nums) + +def bubble_sort(list_of_nums): + # Check if it is a valid input. + if not list_of_nums or not isinstance(list_of_nums, list): + # If not a valid input return empty list. + return [] + + # Return bubble sort recursive solution + return recursive_sort(list_of_nums, len(list_of_nums)) + +def recursive_sort(list_of_nums, len): + # Basic case. + if len == 1: + return list_of_nums + + # Order sublist. + for i in range(len-1): + if list_of_nums[i] > list_of_nums[i+1]: + list_of_nums[i], list_of_nums[i+1] = list_of_nums[i+1], list_of_nums[i] + + return recursive_sort(list_of_nums, len-1) From 49c859295118db1a5a19f75f201cf367599a9931 Mon Sep 17 00:00:00 2001 From: Saksham Sharma <89659787+SakshamSharma07@users.noreply.github.com> Date: Sun, 16 Oct 2022 14:54:56 +0530 Subject: [PATCH 69/81] solution.py --- .../solution.py | 14 ++++++++++++++ .../tempCodeRunnerFile.py | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py diff --git a/easy/right_angle_triangle_pattern_with_number/solution.py b/easy/right_angle_triangle_pattern_with_number/solution.py index e69de29..dcfa173 100644 --- a/easy/right_angle_triangle_pattern_with_number/solution.py +++ b/easy/right_angle_triangle_pattern_with_number/solution.py @@ -0,0 +1,14 @@ +def solution(n=-1): + if n==-1: + return -1 + if n<1: + return -1 + string= "" + if(n>0): + for row in range(n): + for column in range(row+1): + string+=str(column+1) + if row==n-1: + break + string+="\n" + return string \ No newline at end of file diff --git a/easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py b/easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py new file mode 100644 index 0000000..47e6664 --- /dev/null +++ b/easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py @@ -0,0 +1,12 @@ +def solution(n): + if n<1: + return -1; + string= "" + if(n>0): + for row in range(n): + for column in range(row+1): + string+=str(column+1) + if row==n-1: + break + string+="\n" + return \ No newline at end of file From 868de0f39cbc36ab5eb27a20b8e895705a0a9d4a Mon Sep 17 00:00:00 2001 From: Shailesh Kumar Date: Sun, 16 Oct 2022 15:43:05 +0530 Subject: [PATCH 70/81] Revert "solution for pattern printing with numbers" --- easy/binary_search_recursion/solution.py | 41 +------------------ easy/binary_search_recursion/tests.py | 12 +++--- .../solution.py | 14 ------- .../tempCodeRunnerFile.py | 12 ------ 4 files changed, 8 insertions(+), 71 deletions(-) delete mode 100644 easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py diff --git a/easy/binary_search_recursion/solution.py b/easy/binary_search_recursion/solution.py index f43e4cf..4d6454c 100644 --- a/easy/binary_search_recursion/solution.py +++ b/easy/binary_search_recursion/solution.py @@ -1,39 +1,2 @@ -# Python3 Program for recursive binary search. -def solution(arr, l, r, x): - - # Check base case - if r >= l: - - mid = l + (r - l) // 2 - - # If element is present at the middle itself - if arr[mid] == x: - return mid - - # If element is smaller than mid, then it - # can only be present in left subarray - elif arr[mid] > x: - return solution(arr, l, mid-1, x) - - # Else the element can only be present - # in right subarray - else: - return solution(arr, mid + 1, r, x) - - else: - # Element is not present in the array - return -1 - - -# Driver Code -arr = [2, 3, 4, 10, 40] -x = 10 - -# Function call -result = solution(arr, 0, len(arr)-1, x) - -if result != -1: - print("Element is present at index % d" % result) -else: - print("Element is not present in array") - +def solution(): + pass diff --git a/easy/binary_search_recursion/tests.py b/easy/binary_search_recursion/tests.py index 72dfabf..36f262c 100644 --- a/easy/binary_search_recursion/tests.py +++ b/easy/binary_search_recursion/tests.py @@ -6,23 +6,23 @@ class Test(unittest.TestCase): "Binary Search Test" def test_binary_search_test_a(self): "Normal Test 1" - self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 3), 2, "Test 1 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5], 3), 2, "Test 1 Failed") def test_binary_search_test_b(self): "Normal Test 2" - self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 5), 4, "Test 2 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5], 5), 4, "Test 2 Failed") def test_binary_search_test_c(self): "Normal Test 3" - self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 1), 0, "Test 3 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5], 1), 0, "Test 3 Failed") def test_binary_search_test_d(self): "Normal Test 4" - self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 0), -1, "Test 4 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5], 0), -1, "Test 4 Failed") def test_binary_search_test_e(self): "Normal Test 5" - self.assertEqual(solution([1, 2, 3, 4, 5],0,4, 6), -1, "Test 5 Failed") + self.assertEqual(solution([1, 2, 3, 4, 5], 6), -1, "Test 5 Failed") def test_binary_search_test_i(self): "Exception Test 1" @@ -42,4 +42,4 @@ def test_binary_search_test_l(self): if __name__ == "__main__": - utility.main() + utility.main() \ No newline at end of file diff --git a/easy/right_angle_triangle_pattern_with_number/solution.py b/easy/right_angle_triangle_pattern_with_number/solution.py index dcfa173..e69de29 100644 --- a/easy/right_angle_triangle_pattern_with_number/solution.py +++ b/easy/right_angle_triangle_pattern_with_number/solution.py @@ -1,14 +0,0 @@ -def solution(n=-1): - if n==-1: - return -1 - if n<1: - return -1 - string= "" - if(n>0): - for row in range(n): - for column in range(row+1): - string+=str(column+1) - if row==n-1: - break - string+="\n" - return string \ No newline at end of file diff --git a/easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py b/easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py deleted file mode 100644 index 47e6664..0000000 --- a/easy/right_angle_triangle_pattern_with_number/tempCodeRunnerFile.py +++ /dev/null @@ -1,12 +0,0 @@ -def solution(n): - if n<1: - return -1; - string= "" - if(n>0): - for row in range(n): - for column in range(row+1): - string+=str(column+1) - if row==n-1: - break - string+="\n" - return \ No newline at end of file From 92c914dbe1a6ea1e756df4f85f49643a1a898259 Mon Sep 17 00:00:00 2001 From: Shantanu Rajput <90391285+neutralWire@users.noreply.github.com> Date: Mon, 17 Oct 2022 12:31:09 +0530 Subject: [PATCH 71/81] commit in normal test 3 \n was missing in the given test case --- easy/inverted_right_angle_triangle_pattern/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easy/inverted_right_angle_triangle_pattern/tests.py b/easy/inverted_right_angle_triangle_pattern/tests.py index 0638c72..e5c27d0 100644 --- a/easy/inverted_right_angle_triangle_pattern/tests.py +++ b/easy/inverted_right_angle_triangle_pattern/tests.py @@ -15,7 +15,7 @@ def test_half_diamond_b(self): def test_half_diamond_c(self): """Normal Test 3""" - self.assertEqual(solution(7), "*******\n******\n*****\n****\n***\n**\*", "Normal Test 3 Failed") + self.assertEqual(solution(7), "*******\n******\n*****\n****\n***\n**\n*", "Normal Test 3 Failed") def test_half_diamond_d(self): """Normal Test 4""" From 490903d4a3d721c2fdea74d8d270b19f3aa172a4 Mon Sep 17 00:00:00 2001 From: Shantanu Rajput Date: Mon, 17 Oct 2022 12:39:19 +0530 Subject: [PATCH 72/81] Solution for Inverted Right Angle Triangle Problem --- .../solution.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/easy/inverted_right_angle_triangle_pattern/solution.py b/easy/inverted_right_angle_triangle_pattern/solution.py index e69de29..f46b01d 100644 --- a/easy/inverted_right_angle_triangle_pattern/solution.py +++ b/easy/inverted_right_angle_triangle_pattern/solution.py @@ -0,0 +1,14 @@ +def solution(n=-1): + if n==-1: + return -1 + if n<1: + return -1 + string= "" + if(n>0): + for row in range(n): + for column in range(n-row): + string+="*" + if row==n-1: + break + string+="\n" + return string \ No newline at end of file From 41d94ac09dc5e85c36b24eeeffdd0ef9a0fed4be Mon Sep 17 00:00:00 2001 From: Shantanu Rajput <90391285+neutralWire@users.noreply.github.com> Date: Mon, 17 Oct 2022 21:52:38 +0530 Subject: [PATCH 73/81] commit in test cases In Normal Test Case 3 and 4 \n was missing and \m was writtern instead of \n respectively. --- .../tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easy/inverted_right_angle_triangle_pattern_with_number/tests.py b/easy/inverted_right_angle_triangle_pattern_with_number/tests.py index 5beb798..dfa0d0a 100644 --- a/easy/inverted_right_angle_triangle_pattern_with_number/tests.py +++ b/easy/inverted_right_angle_triangle_pattern_with_number/tests.py @@ -15,11 +15,11 @@ def test_half_diamond_b(self): def test_half_diamond_c(self): """Normal Test 3""" - self.assertEqual(solution(7), "1234567\n123456\n12345\n1234\n123\n12\1", "Normal Test 3 Failed") + self.assertEqual(solution(7), "1234567\n123456\n12345\n1234\n123\n12\n1", "Normal Test 3 Failed") def test_half_diamond_d(self): """Normal Test 4""" - self.assertEqual(solution(9), "123456789\n12345678\m1234567\n123456\n12345\n1234\n123\n12\n1", "Normal Test 4 Failed") + self.assertEqual(solution(9), "123456789\n12345678\n1234567\n123456\n12345\n1234\n123\n12\n1", "Normal Test 4 Failed") def test_half_diamond_e(self): """Exception Test 1""" From faf57fe937283c691f6bf7cd22a78e0e05bf6480 Mon Sep 17 00:00:00 2001 From: Srishti Date: Mon, 17 Oct 2022 21:59:08 +0530 Subject: [PATCH 74/81] solution for inverted right angled triangle with numbers --- .../solution.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/easy/inverted_right_angle_triangle_pattern_with_number/solution.py b/easy/inverted_right_angle_triangle_pattern_with_number/solution.py index e69de29..1e95103 100644 --- a/easy/inverted_right_angle_triangle_pattern_with_number/solution.py +++ b/easy/inverted_right_angle_triangle_pattern_with_number/solution.py @@ -0,0 +1,14 @@ +def solution(n=-1): + if n==-1: + return -1 + if n<1: + return -1 + string= "" + if(n>0): + for row in range(n): + for column in range(n-row): + string+=str(column+1) + if row==n-1: + break + string+="\n" + return string \ No newline at end of file From 0c0e41a4c81368a9150bec4f4bc9452121493989 Mon Sep 17 00:00:00 2001 From: Anamaya Sharma <73896949+Anamaya1729@users.noreply.github.com> Date: Mon, 17 Oct 2022 22:05:43 +0530 Subject: [PATCH 75/81] Revert "Solution for inverted right angled triangle with numbers" --- .../solution.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/easy/inverted_right_angle_triangle_pattern_with_number/solution.py b/easy/inverted_right_angle_triangle_pattern_with_number/solution.py index 1e95103..e69de29 100644 --- a/easy/inverted_right_angle_triangle_pattern_with_number/solution.py +++ b/easy/inverted_right_angle_triangle_pattern_with_number/solution.py @@ -1,14 +0,0 @@ -def solution(n=-1): - if n==-1: - return -1 - if n<1: - return -1 - string= "" - if(n>0): - for row in range(n): - for column in range(n-row): - string+=str(column+1) - if row==n-1: - break - string+="\n" - return string \ No newline at end of file From 46ef12289328ba6059eb925cc5915860e3bd7481 Mon Sep 17 00:00:00 2001 From: srishti309 Date: Tue, 18 Oct 2022 17:44:32 +0530 Subject: [PATCH 76/81] solution for inverted right angled triangle with number --- .../solution.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/easy/inverted_right_angle_triangle_pattern_with_number/solution.py b/easy/inverted_right_angle_triangle_pattern_with_number/solution.py index e69de29..1e95103 100644 --- a/easy/inverted_right_angle_triangle_pattern_with_number/solution.py +++ b/easy/inverted_right_angle_triangle_pattern_with_number/solution.py @@ -0,0 +1,14 @@ +def solution(n=-1): + if n==-1: + return -1 + if n<1: + return -1 + string= "" + if(n>0): + for row in range(n): + for column in range(n-row): + string+=str(column+1) + if row==n-1: + break + string+="\n" + return string \ No newline at end of file From a7e8c23f0bd387010507058b82341543902e4118 Mon Sep 17 00:00:00 2001 From: Ahmad Syafrudin Date: Tue, 18 Oct 2022 20:39:47 +0700 Subject: [PATCH 77/81] added solution.py for palindrome recursion --- easy/palindrome_recursion/README.md | 2 +- easy/palindrome_recursion/solution.py | 21 +++++++++++++++++++++ easy/palindrome_recursion/tests.py | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/easy/palindrome_recursion/README.md b/easy/palindrome_recursion/README.md index 4e3102c..6aaaf16 100644 --- a/easy/palindrome_recursion/README.md +++ b/easy/palindrome_recursion/README.md @@ -22,7 +22,7 @@ n = 21312 ``` #### Explanation -The 21312 is same from fornt as well as back. +The 21312 is same from front as well as back. #### Testing Run the following command: diff --git a/easy/palindrome_recursion/solution.py b/easy/palindrome_recursion/solution.py index e69de29..880b93a 100644 --- a/easy/palindrome_recursion/solution.py +++ b/easy/palindrome_recursion/solution.py @@ -0,0 +1,21 @@ +from typing import Optional + + +def solution(number: Optional[int] = None): + if number is None or number < 0: + return -1 + current_word = str(number) + if len(current_word) < 2: + return 1 + if len(current_word) < 2: + return 1 + else: + first_letter = current_word[0] + last_letter = current_word[len(current_word) - 1] + if first_letter == last_letter: + middle_word = current_word[1:len(current_word) - 1] + if middle_word == '': + return 1 + return solution(int(middle_word)) + else: + return 0 diff --git a/easy/palindrome_recursion/tests.py b/easy/palindrome_recursion/tests.py index df840ef..125a51c 100644 --- a/easy/palindrome_recursion/tests.py +++ b/easy/palindrome_recursion/tests.py @@ -2,6 +2,7 @@ import utility from solution import solution + class Test(unittest.TestCase): """Palindrome Check""" From f5738ef60695a1a5cc2860d6d2c5f42e09511fe3 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 18 Oct 2022 19:29:15 +0530 Subject: [PATCH 78/81] updated the file easy/sum_of_n_numbers/solution.py --- easy/sum_of_n_numbers/solution.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/easy/sum_of_n_numbers/solution.py b/easy/sum_of_n_numbers/solution.py index e69de29..cdfbc2c 100644 --- a/easy/sum_of_n_numbers/solution.py +++ b/easy/sum_of_n_numbers/solution.py @@ -0,0 +1,11 @@ +def solution(n): + sum = 0 + if not str(n).isnumeric(): + sum = -1 + return sum + else: + n = int(n) + for i in range(n): + i = i + 1 + sum = sum + i + return sum \ No newline at end of file From 68394a7b9b908192bd6d6ca828076375d4a63c50 Mon Sep 17 00:00:00 2001 From: anamaya Date: Wed, 19 Oct 2022 00:11:28 +0530 Subject: [PATCH 79/81] added linear regression implementation from scratch --- hard/linear_regression/solution.py | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hard/linear_regression/solution.py b/hard/linear_regression/solution.py index e69de29..d3f3d4e 100644 --- a/hard/linear_regression/solution.py +++ b/hard/linear_regression/solution.py @@ -0,0 +1,35 @@ +import numpy as np + +class LinearRegression(): + + def __init__(self): + self.w = None + self.b = None + + def fit(self, X, y, lr=0.01, epochs=100): + self.w = np.zeros(X.shape[1]) + self.b = 0 + for _ in range(epochs): + y_pred = self.predict(X) + dw = np.mean((y_pred - y) * X, axis=0) + db = np.mean(y_pred - y) + self.w -= lr * dw + self.b -= lr * db + + def predict(self, X): + return X @ self.w + self.b + + def score(self, X, y): + y_pred = self.predict(X) + return 1 - np.sum((y - y_pred) ** 2) / np.sum((y - np.mean(y)) ** 2) + +def main(): + X = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + m, c = 2, 3 + y = m * X[:, 0] + c + model = LinearRegression() + model.fit(X, y) + print(f"Accuracy: {model.score(X, y)}") + +if __name__ == '__main__': + main() \ No newline at end of file From 4997d805ead872778ce0d6bc470f9db7595454ed Mon Sep 17 00:00:00 2001 From: Suhas2002 Date: Tue, 25 Oct 2022 13:14:25 +0530 Subject: [PATCH 80/81] Update solution.py --- easy/calculator/solution.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/easy/calculator/solution.py b/easy/calculator/solution.py index 4d6454c..4d53a45 100644 --- a/easy/calculator/solution.py +++ b/easy/calculator/solution.py @@ -1,2 +1,27 @@ def solution(): pass +def solution(num1, num2, op =""): + if(op == "+"): + n1 = str(num1) + n2 = str(num2) + if not n1.isdigit() and not n2.isdigit(): + return -1 + else: + calc = num1 + num2 + return calc + elif(op == "-"): + calc = num1 - num2 + return calc + elif(op == "*"): + calc = num1 * num2 + return calc + elif(op == "/"): + if(num2 == 0): + return -1 + else: + calc = num1 / num2 + return calc + else: + return -1 + + From 6a4da259780e53ecfd0701f8309162a7d835e5c2 Mon Sep 17 00:00:00 2001 From: Suhas2002 Date: Tue, 25 Oct 2022 13:21:25 +0530 Subject: [PATCH 81/81] Update solution.py --- easy/calculator/solution.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/easy/calculator/solution.py b/easy/calculator/solution.py index 4d53a45..5e1956a 100644 --- a/easy/calculator/solution.py +++ b/easy/calculator/solution.py @@ -1,5 +1,3 @@ -def solution(): - pass def solution(num1, num2, op =""): if(op == "+"): n1 = str(num1)