wrequiems

Untitled

Feb 28th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class Photo:
  2. def __init__(self, i, photo_line):
  3. photo_line = photo_line.split(' ')
  4. self.id = i
  5. self.orientation = photo_line[0]
  6. self.no_tags = int(photo_line[1])
  7. self.tags = set(photo_line[1:])
  8.  
  9. def __repr__(self):
  10. return json.dumps({
  11. "id": self.id,
  12. "orientation": self.orientation,
  13. "no_tags": self.no_tags,
  14. "tags": list(self.tags)
  15. })
  16.  
  17. def score(self, photo):
  18. common_tags = len(photo.tags.intersection(self.tags))
  19. return min(self.no_tags - common_tags, common_tags, photo.no_tags - common_tags)
Advertisement
Add Comment
Please, Sign In to add comment