diff --git a/.all-contributorsrc b/.all-contributorsrc index 4342ac5d..c595884a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -328,6 +328,16 @@ "doc", "code" ] + }, + { + "login": "NormalVad", + "name": "NormalVad", + "avatar_url": "https://avatars2.githubusercontent.com/u/73097046?v=4", + "profile": "https://github.com/NormalVad", + "contributions": [ + "doc", + "code" + ] } ], "commitConvention": "none" diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 39699d08..5c51040f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -49,6 +49,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds <td align="center"><a href="https://github.com/gaurav01k3"><img src="https://avatars0.githubusercontent.com/u/67451786?v=4?s=100" width="100px;" alt=""/><br /><sub><b>GAURAV KUMAR</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=gaurav01k3" title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=gaurav01k3" title="Code">💻</a></td> <td align="center"><a href="https://github.com/wboccard"><img src="https://avatars3.githubusercontent.com/u/72316984?v=4?s=100" width="100px;" alt=""/><br /><sub><b>wboccard</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=wboccard" title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=wboccard" title="Code">💻</a></td> <td align="center"><a href="https://github.com/d-l-mcbride"><img src="https://avatars3.githubusercontent.com/u/46550732?v=4?s=100" width="100px;" alt=""/><br /><sub><b>d-l-mcbride</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=d-l-mcbride" title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=d-l-mcbride" title="Code">💻</a></td> + <td align="center"><a href="https://github.com/NormalVad"><img src="https://avatars2.githubusercontent.com/u/73097046?v=4" width="100px;" alt=""/><br /><sub><b>NormalVad</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=NormalVad" title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=NormalVad" title="Code">💻</a></td> </tr> </table> diff --git a/day14/Python/Product.py b/day14/Python/Product.py new file mode 100644 index 00000000..18f90e47 --- /dev/null +++ b/day14/Python/Product.py @@ -0,0 +1,28 @@ +""" +@author: NormalVad +@date: 25/10/2020 +""" + +def product(a,b): + if(a==0 or b==0): + return 0 + elif(b == 1): + return a + elif(a<0 and b<0): + a = a*(-1) + b = b*(-1) + return a + product(a,b-1) + elif(a>0 and b>0): + return a+product(a,b-1) + elif(a<0 and b>0): + a = a*(-1) + x = a+product(a,b-1) + return x*(-1) + else: + b = b*(-1) + x = a+product(a,b-1) + return x*(-1) + +print("Enter two numbers to be multiplied seperated by a space") +(a,b) = list(map(int, input().split())) +print(product(a,b)) diff --git a/day14/README.md b/day14/README.md index af3bc76d..c93c14eb 100644 --- a/day14/README.md +++ b/day14/README.md @@ -495,3 +495,35 @@ void main(){ } ``` +### Python Implementation + +#### [Solution](./python/Product.py) +```python +""" +@author:NormalVad +@date:25/10/2020 +""" +def product(a,b): + if(a==0 or b==0): + return 0 + elif(b == 1): + return a + elif(a<0 and b<0): + a = a*(-1) + b = b*(-1) + return a + product(a,b-1) + elif(a>0 and b>0): + return a+product(a,b-1) + elif(a<0 and b>0): + a = a*(-1) + x = a+product(a,b-1) + return x*(-1) + else: + b = b*(-1) + x = a+product(a,b-1) + return x*(-1) + +print("Enter two numbers to be multiplied seperated by a space") +(a,b) = list(map(int, input().split())) +print(product(a,b)) +``` diff --git a/day28/Python/LinearSearch.py b/day28/Python/LinearSearch.py new file mode 100644 index 00000000..bd2de62d --- /dev/null +++ b/day28/Python/LinearSearch.py @@ -0,0 +1,26 @@ +""" +@author:NormalVad +@date:25/10/2020 +""" + + +def LinearSearch(a,n): + l = len(a) + found = False + i = 0 + while(i<l): + if(a[i]==n): + found = True + break + else: + i += 1 + if(found): + return i + else: + return "Undefined" + +print("Please input Elements of array in single line seperated by spaces") +arr = list(map(int, input().split())) +print("Input element to be found") +n = int(input()) +print(LinearSearch(arr,n)) diff --git a/day28/README.md b/day28/README.md index 5d266d6b..c059aa0f 100644 --- a/day28/README.md +++ b/day28/README.md @@ -163,3 +163,36 @@ void main(){ } } ``` +## Python Implementation + +### [Solution](./Python/linearSearch.py) +```python + +""" +@author:NormalVad +@date:25/10/2020 +""" + + +def LinearSearch(a,n): + l = len(a) + found = False + i = 0 + while(i<l): + if(a[i]==n): + found = True + break + else: + i += 1 + if(found): + return i + else: + return "Undefined" + +print("Please input Elements of array in single line seperated by spaces") +arr = list(map(int, input().split())) +print("Input element to be found") +n = int(input()) +print(LinearSearch(arr,n)) +``` +