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
GAURAV KUMAR

📖 💻
wboccard

📖 💻
d-l-mcbride

📖 💻 +
NormalVad

📖 💻 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