Created
March 3, 2019 03:48
-
-
Save graphoarty/b6c7cd20a55bb979354a008f02392004 to your computer and use it in GitHub Desktop.
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
def cartesianProduct(setA, setB): | |
if len(setA) == 0: | |
return None | |
if len(setB) == 0: | |
return None | |
product = [] | |
for elementA in setA: | |
for elementB in setB: | |
product.append([elementA, elementB]) | |
return product | |
print(cartesianProduct(['a', 'b'], ['1', '2', '3'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment