I maintain a set that needs to be progressively shrunk, according to various conditions.
For example:
acceptable = read_input()
acceptable.rank_by_x()
acceptable = set(filter(is_rank_x_top_100, acceptable))
acceptable.rank_by_y()
acceptable = set(filter(is_rank_y_top_10, acceptable))
It works, but the set(filter()) construct looks ugly. Is there a better way to do that? Or is it better to just subclass set to add a method that does the same?
You may collapse this to:
Or use comprehensions: