Created
June 25, 2018 07:05
-
-
Save glipR/94f0ca2863b28fd42261db637f5ad7d3 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
target = int(input()) | |
# Pull the list from input, split by ", " character, and convert to integers | |
pair_list = list(map(int, input().split(", "))) | |
# Create a set (all unique elements from the list) | |
pair_set = set(pair_list) | |
results = [] | |
for item1 in pair_set: | |
for item2 in pair_set: | |
# Only one of each pair, so force them ascending | |
if item1 <= item2: | |
# If they meet the criteria | |
if item1+item2 = target: | |
if item1 != item2: | |
results.append((item1, item2)) | |
else: | |
# Make sure that we have more than one element to make a pair | |
if pair_list.count(item1) > 1: | |
results.append((item1, item2)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment