Skip to content

Commit

Permalink
Day 10 Python implementation (#104)
Browse files Browse the repository at this point in the history
* Add @aaditkamat as a contributor

* Add Ruby code for Day 1: FizzBuzz problem

* Add Ruby code for Day 2: String reverse problem

* Update README.md for Day 2

* Modify Ruby code and README

* Add condition for nil and wrong type edge cases

* Add a seperate Ruby source code file for palindrome

* Modify code for reverse.rb

* Add seperate palindrome and reverse code sections in README

* Update gitignore

* Refactor palindrome.rb and rename heading in README

* Add solution for Day 3: Hamming Problem

* Add condition for strings of unequal lengths

* Update README

* Change project name and owner in.all-contributorsrc

* Remove merge conflict lines

* Add @shivank86 as a contributor

* Add C++ files for different patterns

* Add author and date comments at the top of C++ files

* Update README.md

* Add solution for Day 6 Problem in Python

* Update README

* Refactor code files

* Modify string representation of output in python files

* Add Ruby solutions for Day 6 problem

* Update README for Ruby code

* Add first version of solutions for Day 7 problem in C++, Java & Ruby

* Modify solutions

* Update Day 7 README

* Remove merge conflicts from CONTRIBUTORS.md

* Add back removed lines in CONTRIBUTORS.md

* Add code sections contributed by @imkaka to day 6 README

* Update README.md

* Add C++ solution

* Add Day 8 solution in C++

* Add Day 8 solution in Java

* Add Day 8 solution in Ruby

* Add Day 8 solution in Python

* Add credits at the top of the code

* Update README

* Update C++ implementation

* Update Python implementation

* Add solution for Day 10: String Permutation Problem in Python

Signed-off-by: Aadit Rahul Kamat <aadit.k12@gmail.com>

* Update Day 10 README

Signed-off-by: Aadit Rahul Kamat <aadit.k12@gmail.com>
  • Loading branch information
Aadit Kamat authored and MadhavBahl committed Jan 2, 2019
1 parent 4dc2cae commit c8ef407
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .all-contributorsrc
Expand Up @@ -203,4 +203,4 @@
]
}
]
}
}
29 changes: 29 additions & 0 deletions day10/Python/permutations.py
@@ -0,0 +1,29 @@
'''
@author: aaditkamat
@date: 02/01/2019
'''

def permutations(string):
if (len(string) <= 1):
return [string]
lst = []
for i in range(len(string)):
substring = ''
for j in range(len(string)):
if j != i:
substring += string[j]
lst.extend(list(set(map(lambda x: string[i] + x, permutations(substring)))))
return lst


def printList(string_list):
for string in string_list:
print(string)

def main():
print('Enter a string: ')
string = input()
print(f'The permutations of {string} are:')
printList(permutations(string))

main()
36 changes: 36 additions & 0 deletions day10/README.md
Expand Up @@ -27,3 +27,39 @@ output:
```js
// To Be Added
```

## Python Implementation

### [Solution](./Python/permutations.py)
```python

'''
@author: aaditkamat
@date: 02/01/2019
'''

def permutations(string):
if (len(string) <= 1):
return [string]
lst = []
for i in range(len(string)):
substring = ''
for j in range(len(string)):
if j != i:
substring += string[j]
lst.extend(list(set(map(lambda x: string[i] + x, permutations(substring)))))
return lst


def printList(string_list):
for string in string_list:
print(string)

def main():
print('Enter a string: ')
string = input()
print(f'The permutations of {string} are:')
printList(permutations(string))

main()
```
2 changes: 1 addition & 1 deletion day8/README.md
@@ -1,4 +1,4 @@
![cover](./cover.png)
![cover](./cover.png)

# Day 8 - Maximum Edit Distance (Levenshtein Distance)

Expand Down

0 comments on commit c8ef407

Please sign in to comment.