From 8f076d2ebfce8dea266a9800a19e50ab65a2e590 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Tue, 25 Dec 2018 15:28:37 +0530 Subject: [PATCH 01/18] Add @vishalshirke7 as a contributor --- .all-contributorsrc | 10 ++++++++++ CONTRIBUTORS.md | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index e317d7cf..5ee8701b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -133,6 +133,16 @@ "code", "doc" ] + }, + { + "login": "vishalshirke7", + "name": "Vishal Shirke", + "avatar_url": "https://avatars2.githubusercontent.com/u/25405726?v=4", + "profile": "https://github.com/vishalshirke7", + "contributions": [ + "doc", + "code" + ] } ] } diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0e591e05..3a15848b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,4 +1,4 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors) ## Contributors Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): @@ -7,7 +7,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
MADHAV BAHL](http://madhavbahl.tech/)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=MadhavBahlMD "Code") [📝](#blog-MadhavBahlMD "Blogposts") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=MadhavBahlMD "Documentation") [🎨](#design-MadhavBahlMD "Design") [✅](#tutorial-MadhavBahlMD "Tutorials") | [
Rajdeep Roy Chowdhury](http://www.linkedin.com/in/razdeeproychowdhury)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Razdeep "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Razdeep "Documentation") [✅](#tutorial-Razdeep "Tutorials") | [
Hrishi](https://hrishi1999.github.io)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Hrishi1999 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Hrishi1999 "Code") | [
Bhanu Ailani](https://github.com/Bhanu0202)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Bhanu0202 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Bhanu0202 "Code") | [
Deepak Sharma](https://sourcerer.io/dsdsharma)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dsdsharma "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dsdsharma "Code") | [
Ramanpreet Singh](https://github.com/Ramanpreet6262)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Ramanpreet6262 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Ramanpreet6262 "Code") | [
Anil Khatri](https://imkaka.github.io/)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=imkaka "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=imkaka "Code") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | -| [
Ashwek Swamy](https://github.com/ashwek)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Code") | [
Dhruv Gupta](https://github.com/dhruv-gupta14)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dhruv-gupta14 "Code") | [
Aadit Kamat](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Code") | [
Shashank jain](http://www.myshashank.tech)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Code") | [
Moulik Aggarwal](https://github.com/moulikcipherX)
[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Documentation") | +| [
Ashwek Swamy](https://github.com/ashwek)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Code") | [
Dhruv Gupta](https://github.com/dhruv-gupta14)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dhruv-gupta14 "Code") | [
Aadit Kamat](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Code") | [
Shashank jain](http://www.myshashank.tech)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Code") | [
Moulik Aggarwal](https://github.com/moulikcipherX)
[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Documentation") | [
Vishal Shirke](https://github.com/vishalshirke7)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=vishalshirke7 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=vishalshirke7 "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From 5e96f6d93b51fa115b36c9bd24bbb2d4e2f317c0 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Tue, 25 Dec 2018 15:29:49 +0530 Subject: [PATCH 02/18] Update @vishalshirke7 as a contributor --- .all-contributorsrc | 4 +++- CONTRIBUTORS.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 5ee8701b..6a5dba72 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -141,7 +141,9 @@ "profile": "https://github.com/vishalshirke7", "contributions": [ "doc", - "code" + "code", + "blog", + "tutorial" ] } ] diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3a15848b..aa2a3575 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,7 +7,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
MADHAV BAHL](http://madhavbahl.tech/)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=MadhavBahlMD "Code") [📝](#blog-MadhavBahlMD "Blogposts") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=MadhavBahlMD "Documentation") [🎨](#design-MadhavBahlMD "Design") [✅](#tutorial-MadhavBahlMD "Tutorials") | [
Rajdeep Roy Chowdhury](http://www.linkedin.com/in/razdeeproychowdhury)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Razdeep "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Razdeep "Documentation") [✅](#tutorial-Razdeep "Tutorials") | [
Hrishi](https://hrishi1999.github.io)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Hrishi1999 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Hrishi1999 "Code") | [
Bhanu Ailani](https://github.com/Bhanu0202)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Bhanu0202 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Bhanu0202 "Code") | [
Deepak Sharma](https://sourcerer.io/dsdsharma)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dsdsharma "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dsdsharma "Code") | [
Ramanpreet Singh](https://github.com/Ramanpreet6262)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Ramanpreet6262 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Ramanpreet6262 "Code") | [
Anil Khatri](https://imkaka.github.io/)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=imkaka "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=imkaka "Code") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | -| [
Ashwek Swamy](https://github.com/ashwek)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Code") | [
Dhruv Gupta](https://github.com/dhruv-gupta14)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dhruv-gupta14 "Code") | [
Aadit Kamat](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Code") | [
Shashank jain](http://www.myshashank.tech)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Code") | [
Moulik Aggarwal](https://github.com/moulikcipherX)
[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Documentation") | [
Vishal Shirke](https://github.com/vishalshirke7)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=vishalshirke7 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=vishalshirke7 "Code") | +| [
Ashwek Swamy](https://github.com/ashwek)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=ashwek "Code") | [
Dhruv Gupta](https://github.com/dhruv-gupta14)
[💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=dhruv-gupta14 "Code") | [
Aadit Kamat](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=aaditkamat "Code") | [
Shashank jain](http://www.myshashank.tech)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=Shashankjain12 "Code") | [
Moulik Aggarwal](https://github.com/moulikcipherX)
[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Code") [📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=moulikcipherX "Documentation") | [
Vishal Shirke](https://github.com/vishalshirke7)
[📖](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=vishalshirke7 "Documentation") [💻](https://github.com/MadhavBahlMD/DailyCodeBase/commits?author=vishalshirke7 "Code") [📝](#blog-vishalshirke7 "Blogposts") [✅](#tutorial-vishalshirke7 "Tutorials") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From 1ea674f2d9b9725bd4f2fbb10219e81987358596 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Tue, 25 Dec 2018 16:37:28 +0530 Subject: [PATCH 03/18] Added python solutions for Day 4 --- day4/Python/MaxChars.py | 19 +++++++++++++++++++ day4/Python/NumOfVowels.py | 13 +++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 day4/Python/MaxChars.py create mode 100644 day4/Python/NumOfVowels.py diff --git a/day4/Python/MaxChars.py b/day4/Python/MaxChars.py new file mode 100644 index 00000000..82b3122f --- /dev/null +++ b/day4/Python/MaxChars.py @@ -0,0 +1,19 @@ +""" + @author : vishalshirke7 + @date : 25/12/2018 +""" + +input_str = input() +dictnry = {} +maxCount, maxChar = 0, '' +for char in input_str: + if char in dictnry.keys(): + dictnry[char] += 1 + else: + dictnry[char] = 1 + if dictnry[char] > maxCount: + maxCount = dictnry[char] + maxChar = char + +print(maxChar) + diff --git a/day4/Python/NumOfVowels.py b/day4/Python/NumOfVowels.py new file mode 100644 index 00000000..b51efb40 --- /dev/null +++ b/day4/Python/NumOfVowels.py @@ -0,0 +1,13 @@ +import re + +""" + @author : vishalshirke7 + @date : 25/12/2018 +""" + +""" +This solution is based on regular expression module in python. +""" + +print(len(re.findall(r'[a,e,i,o,u,A,E,I,O,U]', input()))) + From 3e185fe6895f66b3b0520a45de129151bf73d168 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Tue, 25 Dec 2018 16:57:07 +0530 Subject: [PATCH 04/18] modified readme --- day4/README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/day4/README.md b/day4/README.md index 552721f5..dd0b772b 100644 --- a/day4/README.md +++ b/day4/README.md @@ -216,6 +216,23 @@ public class NumVowels2 { } ``` +## Python Implementation + +### [Solution 1](./Python/NumOfVowels.py) + +```python +import re + +""" + This solution makes use of python's re module i.e regular expressions + Here findall method takes two parameters 1st - regualr expression, 2nd - input string + The regular expression simply checks for all vowels present in the input string + and returns them as a list. +""" +print(len(re.findall(r'[a,e,i,o,u,A,E,I,O,U]', input()))) + +``` +
## Part B -- Max Chars Problem @@ -291,3 +308,33 @@ function maxChars (sentence) { maxChars('helllllo worlld'); ``` + +## Python Implementation + +### [Solution 1](./Python/MaxChars.py) + +```python +input_str = input() +dictnry = {} +maxCount, maxChar = 0, '' +for char in input_str: + """ + In this solution we are simply maintaining a dictionary of characters + in the input string as key and their count as value + """ + if char in dictnry.keys(): + dictnry[char] += 1 + else: + dictnry[char] = 1 + """ + We check for maxCount of each character in a single loop + by comparing it with present maxCount, hence not iterating over the dictionary again + to find character with maximum count. + """ + if dictnry[char] > maxCount: + maxCount = dictnry[char] + maxChar = char + +print(maxChar) + +``` From df272bed6338aa2b5580126f5a9f34218d988743 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Wed, 26 Dec 2018 12:56:43 +0530 Subject: [PATCH 05/18] Add @vishal --- .all-contributorsrc | 148 +++----------------------------------------- CONTRIBUTORS.md | 7 ++- 2 files changed, 13 insertions(+), 142 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index ff5946d5..373a71df 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7,152 +7,18 @@ "CONTRIBUTORS.md" ], "imageSize": 100, - "commit": true, + "commit": false, "contributors": [ { - "login": "MadhavBahlMD", - "name": "MADHAV BAHL", - "avatar_url": "https://avatars2.githubusercontent.com/u/26179770?v=4", - "profile": "http://madhavbahl.tech/", + "login": "vishalshirke7", + "name": "Vishal Shirke", + "avatar_url": "https://avatars2.githubusercontent.com/u/25405726?v=4", + "profile": "https://github.com/vishalshirke7", "contributions": [ - "code", - "blog", "doc", - "design", - "tutorial" - ] - }, - { - "login": "Razdeep", - "name": "Rajdeep Roy Chowdhury", - "avatar_url": "https://avatars2.githubusercontent.com/u/32531173?v=4", - "profile": "http://www.linkedin.com/in/razdeeproychowdhury", - "contributions": [ "code", - "doc", - "tutorial" - ] - }, - { - "login": "Hrishi1999", - "name": "Hrishi", - "avatar_url": "https://avatars1.githubusercontent.com/u/16208722?v=4", - "profile": "https://hrishi1999.github.io", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "Bhanu0202", - "name": "Bhanu Ailani", - "avatar_url": "https://avatars1.githubusercontent.com/u/33101287?v=4", - "profile": "https://github.com/Bhanu0202", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "dsdsharma", - "name": "Deepak Sharma", - "avatar_url": "https://avatars3.githubusercontent.com/u/35690440?v=4", - "profile": "https://sourcerer.io/dsdsharma", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "Ramanpreet6262", - "name": "Ramanpreet Singh", - "avatar_url": "https://avatars2.githubusercontent.com/u/28749866?v=4", - "profile": "https://github.com/Ramanpreet6262", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "imkaka", - "name": "Anil Khatri", - "avatar_url": "https://avatars1.githubusercontent.com/u/27620628?v=4", - "profile": "https://imkaka.github.io/", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "ashwek", - "name": "Ashwek Swamy", - "avatar_url": "https://avatars0.githubusercontent.com/u/39827514?v=4", - "profile": "https://github.com/ashwek", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "dhruv-gupta14", - "name": "Dhruv Gupta", - "avatar_url": "https://avatars1.githubusercontent.com/u/32368107?v=4", - "profile": "https://github.com/dhruv-gupta14", - "contributions": [ - "code" - ] - }, - { - "login": "aaditkamat", - "name": "Aadit Kamat", - "avatar_url": "https://avatars0.githubusercontent.com/u/30969577?v=4", - "profile": "https://sg.linkedin.com/in/aadit-kamat-12a5a8140", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "Shashankjain12", - "name": "Shashank jain", - "avatar_url": "https://avatars1.githubusercontent.com/u/20285786?v=4", - "profile": "http://www.myshashank.tech", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "moulikcipherX", - "name": "Moulik Aggarwal", - "avatar_url": "https://avatars3.githubusercontent.com/u/22260031?v=4", - "profile": "https://github.com/moulikcipherX", - "contributions": [ - "question", - "blog", - "code", - "doc" - ] - }, - { - "login": "prateek3255", - "name": "Prateek Surana", - "avatar_url": "https://avatars3.githubusercontent.com/u/21277179?v=4", - "profile": "http://prateeksurana.me", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "shivank86", - "name": "shivank86", - "avatar_url": "https://avatars2.githubusercontent.com/u/43927436?v=4", - "profile": "https://github.com/shivank86", - "contributions": [ - "code" - ] - } + "tutorial", + "blog" ] } ] diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6dcca79c..5137e132 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,7 +1,12 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) ## Contributors + + +| [
Vishal Shirke](https://github.com/vishalshirke7)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=vishalshirke7 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=vishalshirke7 "Code") [✅](#tutorial-vishalshirke7 "Tutorials") [📝](#blog-vishalshirke7 "Blogposts") | +| :---: | + Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): From 65f23dbe3f3c946628ffed141682271bba3c4b48 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Wed, 26 Dec 2018 13:16:47 +0530 Subject: [PATCH 06/18] reverted adding as a contributor --- .all-contributorsrc | 146 +++++++++++++++++++++++++++++++++++++++++--- CONTRIBUTORS.md | 5 -- 2 files changed, 139 insertions(+), 12 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 373a71df..d8fd76ee 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7,18 +7,150 @@ "CONTRIBUTORS.md" ], "imageSize": 100, - "commit": false, + "commit": true, "contributors": [ { - "login": "vishalshirke7", - "name": "Vishal Shirke", - "avatar_url": "https://avatars2.githubusercontent.com/u/25405726?v=4", - "profile": "https://github.com/vishalshirke7", + "login": "MadhavBahlMD", + "name": "MADHAV BAHL", + "avatar_url": "https://avatars2.githubusercontent.com/u/26179770?v=4", + "profile": "http://madhavbahl.tech/", "contributions": [ + "code", + "blog", "doc", + "design", + "tutorial" + ] + }, + { + "login": "Razdeep", + "name": "Rajdeep Roy Chowdhury", + "avatar_url": "https://avatars2.githubusercontent.com/u/32531173?v=4", + "profile": "http://www.linkedin.com/in/razdeeproychowdhury", + "contributions": [ "code", - "tutorial", - "blog" + "doc", + "tutorial" + ] + }, + { + "login": "Hrishi1999", + "name": "Hrishi", + "avatar_url": "https://avatars1.githubusercontent.com/u/16208722?v=4", + "profile": "https://hrishi1999.github.io", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "Bhanu0202", + "name": "Bhanu Ailani", + "avatar_url": "https://avatars1.githubusercontent.com/u/33101287?v=4", + "profile": "https://github.com/Bhanu0202", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "dsdsharma", + "name": "Deepak Sharma", + "avatar_url": "https://avatars3.githubusercontent.com/u/35690440?v=4", + "profile": "https://sourcerer.io/dsdsharma", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "Ramanpreet6262", + "name": "Ramanpreet Singh", + "avatar_url": "https://avatars2.githubusercontent.com/u/28749866?v=4", + "profile": "https://github.com/Ramanpreet6262", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "imkaka", + "name": "Anil Khatri", + "avatar_url": "https://avatars1.githubusercontent.com/u/27620628?v=4", + "profile": "https://imkaka.github.io/", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "ashwek", + "name": "Ashwek Swamy", + "avatar_url": "https://avatars0.githubusercontent.com/u/39827514?v=4", + "profile": "https://github.com/ashwek", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "dhruv-gupta14", + "name": "Dhruv Gupta", + "avatar_url": "https://avatars1.githubusercontent.com/u/32368107?v=4", + "profile": "https://github.com/dhruv-gupta14", + "contributions": [ + "code" + ] + }, + { + "login": "aaditkamat", + "name": "Aadit Kamat", + "avatar_url": "https://avatars0.githubusercontent.com/u/30969577?v=4", + "profile": "https://sg.linkedin.com/in/aadit-kamat-12a5a8140", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "Shashankjain12", + "name": "Shashank jain", + "avatar_url": "https://avatars1.githubusercontent.com/u/20285786?v=4", + "profile": "http://www.myshashank.tech", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "moulikcipherX", + "name": "Moulik Aggarwal", + "avatar_url": "https://avatars3.githubusercontent.com/u/22260031?v=4", + "profile": "https://github.com/moulikcipherX", + "contributions": [ + "question", + "blog", + "code", + "doc" + ] + }, + { + "login": "prateek3255", + "name": "Prateek Surana", + "avatar_url": "https://avatars3.githubusercontent.com/u/21277179?v=4", + "profile": "http://prateeksurana.me", + "contributions": [ + "doc", + "code" + ] + }, + { + "login": "shivank86", + "name": "shivank86", + "avatar_url": "https://avatars2.githubusercontent.com/u/43927436?v=4", + "profile": "https://github.com/shivank86", + "contributions": [ + "code" ] } ] diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5137e132..7689a637 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,11 +2,6 @@ ## Contributors - - -| [
Vishal Shirke](https://github.com/vishalshirke7)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=vishalshirke7 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=vishalshirke7 "Code") [✅](#tutorial-vishalshirke7 "Tutorials") [📝](#blog-vishalshirke7 "Blogposts") | -| :---: | - Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): From f078b32fc03dbc1079e53f2db189bf101ae2fcf1 Mon Sep 17 00:00:00 2001 From: MADHAV BAHL Date: Wed, 26 Dec 2018 14:14:15 +0530 Subject: [PATCH 07/18] Update README.md --- day4/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/day4/README.md b/day4/README.md index 1ac889e0..04cb71c9 100644 --- a/day4/README.md +++ b/day4/README.md @@ -271,8 +271,6 @@ for i in b: print(count) ``` -
- ## C++ Implementation ### [NumVowelsPartA.cpp](./C++/NumVowelsPartA.cpp) From 5ed238a000ac8eebdd28463ca1265c02770bcd59 Mon Sep 17 00:00:00 2001 From: MADHAV BAHL Date: Wed, 26 Dec 2018 14:20:05 +0530 Subject: [PATCH 08/18] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7689a637..1b8b504c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -8,7 +8,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
MADHAV BAHL](http://madhavbahl.tech/)
[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=MadhavBahlMD "Code") [📝](#blog-MadhavBahlMD "Blogposts") [📖](https://github.com/CodeToExpress/dailycodebase/commits?author=MadhavBahlMD "Documentation") [🎨](#design-MadhavBahlMD "Design") [✅](#tutorial-MadhavBahlMD "Tutorials") | [
Rajdeep Roy Chowdhury](http://www.linkedin.com/in/razdeeproychowdhury)
[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Razdeep "Code") [📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Razdeep "Documentation") [✅](#tutorial-Razdeep "Tutorials") | [
Hrishi](https://hrishi1999.github.io)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Hrishi1999 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Hrishi1999 "Code") | [
Bhanu Ailani](https://github.com/Bhanu0202)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Bhanu0202 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Bhanu0202 "Code") | [
Deepak Sharma](https://sourcerer.io/dsdsharma)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=dsdsharma "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=dsdsharma "Code") | [
Ramanpreet Singh](https://github.com/Ramanpreet6262)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Ramanpreet6262 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Ramanpreet6262 "Code") | [
Anil Khatri](https://imkaka.github.io/)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=imkaka "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=imkaka "Code") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | -| [
Ashwek Swamy](https://github.com/ashwek)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=ashwek "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=ashwek "Code") | [
Dhruv Gupta](https://github.com/dhruv-gupta14)
[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=dhruv-gupta14 "Code") | [
Aadit Kamat](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=aaditkamat "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=aaditkamat "Code") | [
Shashank jain](http://www.myshashank.tech)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Shashankjain12 "Code") | [
Moulik Aggarwal](https://github.com/moulikcipherX)
[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=moulikcipherX "Code") [📖](https://github.com/CodeToExpress/dailycodebase/commits?author=moulikcipherX "Documentation") | [
Prateek Surana](http://prateeksurana.me)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=prateek3255 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=prateek3255 "Code") | [
shivank86](https://github.com/shivank86)
[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=shivank86 "Code") | +| [
Ashwek Swamy](https://github.com/ashwek)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=ashwek "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=ashwek "Code") | [
Dhruv Gupta](https://github.com/dhruv-gupta14)
[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=dhruv-gupta14 "Code") | [
Aadit Kamat](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=aaditkamat "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=aaditkamat "Code") | [
Shashank jain](http://www.myshashank.tech)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Shashankjain12 "Code") | [
Moulik Aggarwal](https://github.com/moulikcipherX)
[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=moulikcipherX "Code") [📖](https://github.com/CodeToExpress/dailycodebase/commits?author=moulikcipherX "Documentation") | [
Prateek Surana](http://prateeksurana.me)
[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=prateek3255 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=prateek3255 "Code") | [
shivank86](https://github.com/shivank86)
[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=shivank86 "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From c51210ce9ffda7636098908b69bfb74e7aae7ce3 Mon Sep 17 00:00:00 2001 From: MADHAV BAHL Date: Wed, 26 Dec 2018 14:20:37 +0530 Subject: [PATCH 09/18] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1b8b504c..5b1917c7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,4 +1,4 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors) ## Contributors From 29426f0c88ccac3b1112d1319662ac015febfb95 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Fri, 28 Dec 2018 13:11:22 +0530 Subject: [PATCH 10/18] Added python solutions for day 7 --- day7/Python/onewordaway.py | 29 +++++++++++++++++++++++++ day7/README.md | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 day7/Python/onewordaway.py diff --git a/day7/Python/onewordaway.py b/day7/Python/onewordaway.py new file mode 100644 index 00000000..b88331b4 --- /dev/null +++ b/day7/Python/onewordaway.py @@ -0,0 +1,29 @@ +""" + @author : vishalshirke7 + @date : 28/12/2018 +""" + + +def check_one_edit_away(str1, str2): + l1, l2 = len(str1), len(str2) + if abs(l1 - l2) > 1: + return False + if l1 == l2: + count = 0 + for i in range(l1): + if str1[i] != str2[i]: + count += 1 + if count > 1: + return False + else: + return True + else: + if len(set(str1) & set(str2)) == min(l1, l2): + return True + else: + return False + + +check_one_edit_away(*(input().split())) + + diff --git a/day7/README.md b/day7/README.md index 48fffcc7..44f82f21 100644 --- a/day7/README.md +++ b/day7/README.md @@ -121,4 +121,48 @@ oneEditAway ("abcdef", "abcde"); // true oneEditAway ("aaa", "abc"); // false oneEditAway ('bc', 'abc'); // true oneEditAway ('abc', 'abced'); // false +``` + +## Python Implementatiom + +### [Solution 1](./Python/onewordaway.py) + +```python +""" + @author : vishalshirke7 + @date : 28/12/2018 + + Method - There are 3 test cases + 1) Difference of length between 2 characters is more than one, then answer is False + 2) If length of both strings is equal then we'll have to check for 2 cases + 2.1) if count of different characters at each position is > 1 then answer is False + 2.2) if count of different characters at each position is < 2 then answer is True + 3) if difference in length of both strings in 1 then we check for intersection of + both strings and if it is equal to min(length1, length2) then answer is true + as we can add a character to minimum length string or remove one from bigger length string +""" + + +def check_one_edit_away(str1, str2): + l1, l2 = len(str1), len(str2) + if abs(l1 - l2) > 1: + return False + if l1 == l2: + count = 0 + for i in range(l1): + if str1[i] != str2[i]: + count += 1 + if count > 1: + return False + else: + return True + else: + if len(set(str1) & set(str2)) == min(l1, l2): + # check for intersection of two strings + return True + else: + return False + + +check_one_edit_away(*(input().split())) # here list unpacking is used ``` \ No newline at end of file From 1dd41953ee0179f4a6aa3e5578413e9ed536a57c Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Mon, 31 Dec 2018 12:55:00 +0530 Subject: [PATCH 11/18] Edited python solution for day 7 --- day7/Python/onewordaway.py | 36 ++++++++++++++++---------- day7/README.md | 52 ++++++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/day7/Python/onewordaway.py b/day7/Python/onewordaway.py index b88331b4..367c64bd 100644 --- a/day7/Python/onewordaway.py +++ b/day7/Python/onewordaway.py @@ -8,20 +8,30 @@ def check_one_edit_away(str1, str2): l1, l2 = len(str1), len(str2) if abs(l1 - l2) > 1: return False - if l1 == l2: - count = 0 - for i in range(l1): - if str1[i] != str2[i]: - count += 1 - if count > 1: - return False - else: - return True - else: - if len(set(str1) & set(str2)) == min(l1, l2): - return True + count = 0 + i, j = 0, 0 + while i < l1 and j < l2: + if str1[i] != str2[j]: + if count == 1: + return False + + if l1 > l2: + i += 1 + elif l2 > l1: + j += 1 + else: + i += 1 + j += 1 + + count += 1 else: - return False + i += 1 + j += 1 + + if i < l1 or j < l2: + count += 1 + + return count == 1 or count == 0 check_one_edit_away(*(input().split())) diff --git a/day7/README.md b/day7/README.md index 5c3684df..a85e3766 100644 --- a/day7/README.md +++ b/day7/README.md @@ -132,36 +132,44 @@ oneEditAway ('abc', 'abced'); // false @author : vishalshirke7 @date : 28/12/2018 - Method - There are 3 test cases + Method - There are 2 test cases 1) Difference of length between 2 characters is more than one, then answer is False - 2) If length of both strings is equal then we'll have to check for 2 cases - 2.1) if count of different characters at each position is > 1 then answer is False - 2.2) if count of different characters at each position is < 2 then answer is True - 3) if difference in length of both strings in 1 then we check for intersection of - both strings and if it is equal to min(length1, length2) then answer is true - as we can add a character to minimum length string or remove one from bigger length string + 2) Traverse both the strings simultaneously + 2.1) if character at 1st position in both strings doesn't match then increment and count and + if it is greater than one return False + 2.2) increment the pointer of max length string + """ - def check_one_edit_away(str1, str2): l1, l2 = len(str1), len(str2) if abs(l1 - l2) > 1: return False - if l1 == l2: - count = 0 - for i in range(l1): - if str1[i] != str2[i]: - count += 1 - if count > 1: - return False - else: - return True - else: - if len(set(str1) & set(str2)) == min(l1, l2): - # check for intersection of two strings - return True + count = 0 + i, j = 0, 0 + while i < l1 and j < l2: + if str1[i] != str2[j]: + if count == 1: + return False + + if l1 > l2: + i += 1 + elif l2 > l1: + j += 1 + else: + i += 1 + j += 1 + + count += 1 else: - return False + i += 1 + j += 1 + + # check for last remaining character in any string, if length are not equal + if i < l1 or j < l2: + count += 1 + + return count == 1 or count == 0 check_one_edit_away(*(input().split())) # here list unpacking is used From 33134d263dd8916eff96ffeba8808aedc2067ca6 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Mon, 31 Dec 2018 13:04:50 +0530 Subject: [PATCH 12/18] Edited python solution for day 7 --- day7/Python/onewordaway.py | 2 +- day7/README.md | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/day7/Python/onewordaway.py b/day7/Python/onewordaway.py index 367c64bd..1d82b542 100644 --- a/day7/Python/onewordaway.py +++ b/day7/Python/onewordaway.py @@ -31,7 +31,7 @@ def check_one_edit_away(str1, str2): if i < l1 or j < l2: count += 1 - return count == 1 or count == 0 + return count <= 1 check_one_edit_away(*(input().split())) diff --git a/day7/README.md b/day7/README.md index a85e3766..c94f0ff0 100644 --- a/day7/README.md +++ b/day7/README.md @@ -135,9 +135,12 @@ oneEditAway ('abc', 'abced'); // false Method - There are 2 test cases 1) Difference of length between 2 characters is more than one, then answer is False 2) Traverse both the strings simultaneously - 2.1) if character at 1st position in both strings doesn't match then increment and count and - if it is greater than one return False - 2.2) increment the pointer of max length string + 2.1) if characters at 1st position in both strings doesn't match then increment count and if + it is greater than one return False + 2.1.1) increment the pointer of max length string else if equal increment both pointers + 2.2) If characters match then increment both pointers + 3) Lastly increment count if any extra remaining character is present in any string + 4) Return True if count is either 0 or 1 else return False """ @@ -169,7 +172,7 @@ def check_one_edit_away(str1, str2): if i < l1 or j < l2: count += 1 - return count == 1 or count == 0 + return count <= 1 check_one_edit_away(*(input().split())) # here list unpacking is used From e0335fca11142d63186f84c50d48a37ac29fd3ad Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Wed, 2 Jan 2019 23:33:11 +0530 Subject: [PATCH 13/18] Added python solution for day 10 --- day10/Python/permutations1.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 day10/Python/permutations1.py diff --git a/day10/Python/permutations1.py b/day10/Python/permutations1.py new file mode 100644 index 00000000..6c62df6d --- /dev/null +++ b/day10/Python/permutations1.py @@ -0,0 +1,10 @@ +from itertools import permutations +""" + @author : vishalshirke7 + @date : 28/12/2018 +""" + +ip_str = input() +perm = permutations(list(ip_str), len(ip_str)) +for i in set(list(perm)): + print("".join(map(str, i))) From 8e45003805db0af563140fca5b3f269ae5d78408 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Wed, 2 Jan 2019 23:37:48 +0530 Subject: [PATCH 14/18] Changed readme for day 10 --- day10/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/day10/README.md b/day10/README.md index 21606dce..05774713 100644 --- a/day10/README.md +++ b/day10/README.md @@ -90,6 +90,26 @@ def main(): main() ``` +### [Solution](./Python/permutations.py) +```python + +from itertools import permutations +""" + @author : vishalshirke7 + @date : 28/12/2018 + + This solution makes use of python's in-build permutations function from itertools module + It takes two arguments 1st is the list on which permutation is to be performed and + 2nd is the length of the permutation +""" + +ip_str = input() +perm = permutations(list(ip_str), len(ip_str)) +for i in set(list(perm)): + print("".join(map(str, i))) + +``` + ## Java Implementation ### [Solution](./Java/Permutation.java) From c0c97a5260e0e09d8c9565a9e7a2d1de8c1ad93b Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Thu, 3 Jan 2019 17:46:52 +0530 Subject: [PATCH 15/18] minor changes --- day10/Python/permutations1.py | 2 +- day10/README.md | 4 ++-- day11/Python/lcs.py | 0 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 day11/Python/lcs.py diff --git a/day10/Python/permutations1.py b/day10/Python/permutations1.py index 6c62df6d..f8fe0e8d 100644 --- a/day10/Python/permutations1.py +++ b/day10/Python/permutations1.py @@ -1,7 +1,7 @@ from itertools import permutations """ @author : vishalshirke7 - @date : 28/12/2018 + @date : 02/01/2019 """ ip_str = input() diff --git a/day10/README.md b/day10/README.md index e70ac6df..3a504cda 100644 --- a/day10/README.md +++ b/day10/README.md @@ -154,13 +154,13 @@ def main(): main() ``` -### [Solution](./Python/permutations.py) +### [Solution](./Python/permutations1.py) ```python from itertools import permutations """ @author : vishalshirke7 - @date : 28/12/2018 + @date : 02/01/2019 This solution makes use of python's in-build permutations function from itertools module It takes two arguments 1st is the list on which permutation is to be performed and diff --git a/day11/Python/lcs.py b/day11/Python/lcs.py new file mode 100644 index 00000000..e69de29b From 82df9044a43f242c762a12041fec33b158377123 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Thu, 3 Jan 2019 18:17:57 +0530 Subject: [PATCH 16/18] Python solution for day 11 --- day10/README.md | 4 +-- day11/Python/lcs.py | 53 ++++++++++++++++++++++++++++++++++++++++ day11/README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 2 deletions(-) diff --git a/day10/README.md b/day10/README.md index 3a504cda..bab28a0d 100644 --- a/day10/README.md +++ b/day10/README.md @@ -120,7 +120,7 @@ permut('123'); ## Python Implementation -### [Solution](./Python/permutations.py) +### [Solution1](./Python/permutations.py) ```python ''' @@ -154,7 +154,7 @@ def main(): main() ``` -### [Solution](./Python/permutations1.py) +### [Solution2](./Python/permutations1.py) ```python from itertools import permutations diff --git a/day11/Python/lcs.py b/day11/Python/lcs.py index e69de29b..c6e7f640 100644 --- a/day11/Python/lcs.py +++ b/day11/Python/lcs.py @@ -0,0 +1,53 @@ +""" + @author : vishalshirke7 + @date : 03/01/2019 +""" + + +def lcs(str1, str2): + m, n = len(str1), len(str2) + + L = [[0 for y in range(n + 1)] for x in range(m + 1)] + + for i in range(m + 1): + for j in range(n + 1): + if i == 0 or j == 0: + L[i][j] = 0 + elif str1[i - 1] == str2[j - 1]: + L[i][j] = L[i - 1][j - 1] + 1 + else: + L[i][j] = max(L[i - 1][j], L[i][j - 1]) + + index = L[m][n] + + # Create a character array to store the lcs string + lcs_str = [""] * (index + 1) + lcs_str[index] = "" + + # Start from the right-most-bottom-most corner and + # one by one store characters in lcs[] + i = m + j = n + while i > 0 and j > 0: + + # If current character in X[] and Y are same, then + # current character is part of LCS + if str1[i - 1] == str2[j - 1]: + lcs_str[index - 1] = str1[i - 1] + i -= 1 + j -= 1 + index -= 1 + + # If not same, then find the larger of two and + # go in the direction of larger value + elif L[i - 1][j] > L[i][j - 1]: + i -= 1 + else: + j -= 1 + + print("LCS of " + str1 + " and " + str2 + " is -" + "".join(lcs_str)) + + +lcs(*(input().split())) + + diff --git a/day11/README.md b/day11/README.md index 204d3be0..3352afda 100644 --- a/day11/README.md +++ b/day11/README.md @@ -88,3 +88,62 @@ function longestSubstring (str1, str2) { console.log(longestSubstring ("abcdefg", "xyabcz")); console.log(longestSubstring ("XYXYXYZ", "XYZYX")); ``` + +## Python Implementation + +### [Solution using dynamic programming](./Python/lcs.py) + +```python +""" + @author : vishalshirke7 + @date : 03/01/2019 +""" + + +def lcs(str1, str2): + m, n = len(str1), len(str2) + + L = [[0 for y in range(n + 1)] for x in range(m + 1)] + + for i in range(m + 1): + for j in range(n + 1): + if i == 0 or j == 0: + L[i][j] = 0 + elif str1[i - 1] == str2[j - 1]: + L[i][j] = L[i - 1][j - 1] + 1 + else: + L[i][j] = max(L[i - 1][j], L[i][j - 1]) + + index = L[m][n] + + # Create a character array to store the lcs string + lcs_str = [""] * (index + 1) + lcs_str[index] = "" + + # Start from the right-most-bottom-most corner and + # one by one store characters in lcs[] + i = m + j = n + while i > 0 and j > 0: + + # If current character in X[] and Y are same, then + # current character is part of LCS + if str1[i - 1] == str2[j - 1]: + lcs_str[index - 1] = str1[i - 1] + i -= 1 + j -= 1 + index -= 1 + + # If not same, then find the larger of two and + # go in the direction of larger value + elif L[i - 1][j] > L[i][j - 1]: + i -= 1 + else: + j -= 1 + + print("LCS of " + str1 + " and " + str2 + " is -" + "".join(lcs_str)) + + +lcs(*(input().split())) + +``` From ca212d503da8a8efc12f3a78b4391a46482b459e Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Thu, 3 Jan 2019 18:20:23 +0530 Subject: [PATCH 17/18] Python solution for day10 and day11 --- day11/Python/lcs.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/day11/Python/lcs.py b/day11/Python/lcs.py index c6e7f640..191dd699 100644 --- a/day11/Python/lcs.py +++ b/day11/Python/lcs.py @@ -24,8 +24,6 @@ def lcs(str1, str2): lcs_str = [""] * (index + 1) lcs_str[index] = "" - # Start from the right-most-bottom-most corner and - # one by one store characters in lcs[] i = m j = n while i > 0 and j > 0: From 73dcd30a5c690b80d800e0f0514d28555d9eb675 Mon Sep 17 00:00:00 2001 From: Vishal Shirke Date: Mon, 7 Jan 2019 19:49:58 +0530 Subject: [PATCH 18/18] Added python solution for day 13 --- day13/Python/factorial.py | 16 +++++++++++ day13/Python/fibonacci.py | 31 ++++++++++++++++++++ day13/README.md | 60 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 day13/Python/factorial.py create mode 100644 day13/Python/fibonacci.py diff --git a/day13/Python/factorial.py b/day13/Python/factorial.py new file mode 100644 index 00000000..dcd901f3 --- /dev/null +++ b/day13/Python/factorial.py @@ -0,0 +1,16 @@ +""" + @author : vishalshirke7 + @date : 07/01/2019 +""" + + +def factorial(no): + if no <= 1: + return 1 + else: + return no * factorial(no - 1) + + +n = int(input()) +print("factorial of %d is %d" % (n, factorial(n))) + diff --git a/day13/Python/fibonacci.py b/day13/Python/fibonacci.py new file mode 100644 index 00000000..77b30671 --- /dev/null +++ b/day13/Python/fibonacci.py @@ -0,0 +1,31 @@ +""" + @author : vishalshirke7 + @date : 07/01/2019 +""" + + +# Fibonacci Series using Dynamic Programming +def fibonacci(n): + if n <= 1: + return n + else: + if fib_series[n - 1] == 0: + fib_series[n - 1] = fibonacci(n - 1) + + if fib_series[n - 2] == 0: + fib_series[n - 2] = fibonacci(n - 2) + + fib_series[n] = fib_series[n - 2] + fib_series[n - 1] + return fib_series[n] + + +n = int(input()) +fib_series = [0, 1] +while len(fib_series) < n + 1: + fib_series.append(0) +print(fibonacci(n)) +if n == 0: + print(0) +else: + print(", ".join(map(str, fib_series))) + diff --git a/day13/README.md b/day13/README.md index a531c6a1..e4b96744 100644 --- a/day13/README.md +++ b/day13/README.md @@ -114,6 +114,29 @@ int main() return 0; } ``` + +### Python Implementation + +#### [Solution by @vishalshirke7](./Python/factorial.py) +```python +""" + @author : vishalshirke7 + @date : 07/01/2019 +""" + + +def factorial(no): + if no <= 1: + return 1 + else: + return no * factorial(no - 1) + + +n = int(input()) +print("factorial of %d is %d" % (n, factorial(n))) + +``` + *** *** @@ -230,4 +253,41 @@ int main() cout<<"The "<