Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import itertools
- class Library:
- def __init__(self, lib_array):
- self.count = lib_array[0]
- self.signup = lib_array[1]
- self.books_per_day = lib_array[2]
- self.all_books = lib_array[3]
- precomputed_arr = []
- self.all_books.sort()
- for i in range(0, self.all_books.size(), self.books_per_day):
- precomputed_arr.append(sum(self.all_books[i:(self.books_per_day + i)]))
- self.precomputed_score = precomputed_arr
- def __repr__(self):
- return [self.count, self.signup, self.books_per_day, self.all_books, self.precomputed_score]
- def __repr__(self):
- return str([self.count, self.signup, self.books_per_day, self.all_books, self.precomputed_score])
- class Book:
- def __init__(self, index, score):
- self.index = index
- self.score = score
- def read_library_data(filename):
- with open(filename, "r") as f:
- firstline = f.readline()
- general = firstline.split()
- books = general[0]
- libraries = general[1]
- days_for_scanning = general[2]
- book_scores = f.readline() #todo
- library_array = []
- for lib in f:
- lib_array = lib.split()
- books_in_lib = next(f)
- books_in_library = books_in_lib.split()
- lib_array.append(books_in_library)
- library_array.append(Library(lib_array))
- print library_array
- if __name__ == "__main__":
- read_library_data(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement