Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. import sys
  2. import itertools
  3.  
  4. class Library:
  5.     def __init__(self, lib_array):
  6.         self.count = lib_array[0]
  7.         self.signup = lib_array[1]
  8.         self.books_per_day = lib_array[2]
  9.         self.all_books = lib_array[3]
  10.  
  11.         precomputed_arr = []
  12.         self.all_books.sort()
  13.         for i in range(0, self.all_books.size(), self.books_per_day):
  14.             precomputed_arr.append(sum(self.all_books[i:(self.books_per_day + i)]))
  15.  
  16.         self.precomputed_score  = precomputed_arr
  17.     def __repr__(self):
  18.         return [self.count, self.signup, self.books_per_day, self.all_books, self.precomputed_score]
  19.     def __repr__(self):
  20.         return str([self.count, self.signup, self.books_per_day, self.all_books, self.precomputed_score])
  21.  
  22. class Book:
  23.     def __init__(self, index, score):
  24.         self.index = index
  25.         self.score = score
  26.  
  27. def read_library_data(filename):
  28.     with open(filename, "r") as f:
  29.         firstline =  f.readline()
  30.         general = firstline.split()
  31.         books = general[0]
  32.         libraries = general[1]
  33.         days_for_scanning = general[2]
  34.  
  35.         book_scores = f.readline() #todo
  36.  
  37.         library_array = []
  38.         for lib in f:
  39.             lib_array = lib.split()
  40.             books_in_lib = next(f)
  41.             books_in_library = books_in_lib.split()
  42.             lib_array.append(books_in_library)
  43.             library_array.append(Library(lib_array))
  44.         print library_array
  45.  
  46. if __name__ == "__main__":
  47.     read_library_data(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement