Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 * Edited python solution for day 7 * Edited python solution for day 7 * Added python solution for day 10 * Changed readme for day 10 * minor changes * Python solution for day 11 * Python solution for day10 and day11 * Added python solution for day 13 * python solution for day 14 * Python solution for day 16 * Python solution for day 19
- Loading branch information
1 parent
ce7f629
commit 4d7570a
Showing
3 changed files
with
70 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
@author : vishalshirke7 | ||
@date : 15/01/2019 | ||
""" | ||
|
||
import itertools | ||
|
||
|
||
def cartesian1(*iplists): # method 1 using product function | ||
for element in itertools.product(*iplists): | ||
print(element) | ||
|
||
|
||
def cartesian2(ip1, ip2): # method 2 using iteration | ||
if not ip1 or not ip2: | ||
return None | ||
cartesian_product = [] | ||
for i in ip1: | ||
for j in ip2: | ||
cartesian_product.append((i, j)) | ||
|
||
return cartesian_product | ||
|
||
|
||
ip1 = list(map(int, input().split())) | ||
ip2 = list(map(int, input().split())) | ||
cartesian1(ip1, ip2) | ||
cartesian = cartesian2(ip1, ip2) | ||
for i in cartesian: | ||
print(i) |
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