-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashcode_shared.py
More file actions
28 lines (23 loc) · 835 Bytes
/
hashcode_shared.py
File metadata and controls
28 lines (23 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Library:
'''
Contains an index, a set() of books, and the integer throughput and
signup time for the Library.
'''
def __init__(self, index, books, throughput, signup_time):
self.index = index
self.books = books
self.throughput = throughput
self.signup_time = signup_time
# Order the books by score (decreasing) for ease of use.
self.books.sort(key=lambda b: b.score, reverse=True)
def __str__(self):
return "LIBRARY({}, {}, {})".format(self.index, self.throughput, self.signup_time)
class Book:
'''
Contains an index and score for a Book.
'''
def __init__(self, index, score):
self.index = index
self.score = score
def __str__(self):
return "BOOK({},{})".format(self.index, self.score)