17 lines
617 B
Python
17 lines
617 B
Python
from structs.landmark import Landmark
|
|
|
|
def take_most_important(landmarks: list[Landmark], n_important) -> list[Landmark]:
|
|
"""
|
|
Given a list of landmarks, return the n_important most important landmarks
|
|
Parameters:
|
|
landmarks: list[Landmark] - list of landmarks
|
|
n_important: int - number of most important landmarks to return
|
|
Returns:
|
|
list[Landmark] - list of the n_important most important landmarks
|
|
"""
|
|
|
|
# Sort landmarks by attractiveness (descending)
|
|
sorted_landmarks = sorted(landmarks, key=lambda x: x.attractiveness, reverse=True)
|
|
|
|
return sorted_landmarks[:n_important]
|