Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Photo:
- def __init__(self, i, photo_line):
- photo_line = photo_line.split(' ')
- self.id = i
- self.orientation = photo_line[0]
- self.no_tags = int(photo_line[1])
- self.tags = set(photo_line[1:])
- def __repr__(self):
- return json.dumps({
- "id": self.id,
- "orientation": self.orientation,
- "no_tags": self.no_tags,
- "tags": list(self.tags)
- })
- def score(self, photo):
- common_tags = len(photo.tags.intersection(self.tags))
- return min(self.no_tags - common_tags, common_tags, photo.no_tags - common_tags)
Advertisement
Add Comment
Please, Sign In to add comment