Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. import sys
  2. import itertools
  3. import operator
  4.  
  5. all_books = []
  6.  
  7. class Library:
  8. def __init__(self, lib_array):
  9. self.count = lib_array[0]
  10. self.signup = lib_array[1]
  11. self.books_per_day = lib_array[2]
  12. self.all_books = lib_array[3]
  13.  
  14. self.all_books = list(map(int, self.all_books))
  15. arr3 = []
  16. for value in self.all_books:
  17. arr3.append(all_books[value])
  18.  
  19. precomputed_arr = [0]
  20. sorted_by_score = self.all_books.sort()
  21. for i in range(0, len(self.all_books), int(self.books_per_day)):
  22. result = list(map(int, self.all_books[i:(int(self.books_per_day) + i)]))
  23. result_sums = 0
  24. for j in range(i, (int(self.books_per_day) + i)):
  25. result_sums = result_sums + arr3[j]
  26. precomputed_arr.append(precomputed_arr[-1] + result_sums)
  27.  
  28. self.precomputed_score = precomputed_arr
  29. def __repr__(self):
  30. return [self.count, self.signup, self.books_per_day, self.all_books, self.precomputed_score]
  31. def __repr__(self):
  32. return str([self.count, self.signup, self.books_per_day, self.all_books, self.precomputed_score])
  33.  
  34. def read_library_data(filename):
  35. with open(filename, "r") as f:
  36. firstline = f.readline()
  37. general = firstline.split()
  38. books = general[0]
  39. libraries = general[1]
  40. days_for_scanning = general[2]
  41.  
  42. book_scores = f.readline() #todo
  43. book_scores = book_scores.split()
  44. book_scores = list(map(int, book_scores))
  45.  
  46. for book in book_scores:
  47. all_books.append(int(book))
  48.  
  49. library_array = []
  50. for lib in f:
  51. lib_array = lib.split()
  52. books_in_lib = next(f)
  53. books_in_library = books_in_lib.split()
  54. lib_array.append(books_in_library)
  55. library_array.append(Library(lib_array))
  56. print Library(lib_array)
  57. # print library_array
  58.  
  59. with open(filename + "results", w) as w:
  60.  
  61.  
  62. if __name__ == "__main__":
  63. read_library_data(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement