-
-
Save kwikadi/bf5be61bf8aa348dd1254330da1877a5 to your computer and use it in GitHub Desktop.
pep8
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
import operator | |
def take_coordinates(): | |
n = int(input("Enter the number of points: ")) | |
points = [] | |
for i in range(1, n+1): | |
comma_point = input(f"Enter coordinate {str(i)}, comma separated: ") | |
list_point = list(map(int, comma_point.split(","))) | |
points.append(list_point) | |
return points | |
def generate_undominated(points): | |
points.sort(key=operator.itemgetter(2, 1, 0), reverse=True) | |
return points | |
if __name__ == '__main__': | |
points = take_coordinates() | |
undominated = generate_undominated(points) | |
print(undominated) |
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 take_coordinates(): | |
n = int(input("Enter the number of points: ")) | |
points = [] | |
for i in range(1, n+1): | |
comma_point = input(f"Enter coordinate {str(i)}, comma separated: ") | |
list_point = list(map(int, comma_point.split(","))) | |
points.append(list_point) | |
return points | |
def generate_undominated(points): | |
undominated = [] | |
for i in points: | |
for j in points: | |
if dominated(i, j): | |
break | |
else: | |
undominated.append(i) | |
return undominated | |
def dominated(test_for, test_against): | |
if (test_against[0] >= test_for[0] and | |
test_against[1] >= test_for[1] and | |
test_against[2] >= test_for[2] and | |
sum(test_against) > sum(test_for)): | |
return True | |
return False | |
if __name__ == '__main__': | |
points = take_coordinates() | |
undominated = generate_undominated(points) | |
print(undominated) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment