17 lines
588 B
Python
17 lines
588 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)
|
|
landmarks.sort(key=lambda x: x.attractiveness, reverse=True)
|
|
|
|
return landmarks[:n_important]
|