Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added python solution for day 7 (#77)
* Add @vishalshirke7 as a contributor * Update @vishalshirke7 as a contributor * Added python solutions for Day 4 * modified readme * Add @Vishal * reverted adding as a contributor * Update README.md * Update CONTRIBUTORS.md * Update CONTRIBUTORS.md * Added python solutions for day 7
- Loading branch information
1 parent
a12717a
commit 7e8ed6d
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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())) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters