Advertisement
ivetasand

Untitled

Jun 11th, 2022
1,146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. parsed_json = "Lebron 3 10\nCurry 3 6\nCarmelo 1 3\nLebron 2 15\nCurry 3 34\nCurry 3 36"
  2.  
  3. parsed_list = parsed_json.split("\n")
  4.  
  5. for j in range(1,5):
  6.     d = {}
  7.     for i in range(len(parsed_list)):
  8.         name, point, minute = parsed_list[i].split()
  9.         point = int(point)
  10.         minute = int(minute)
  11.         if minute <= j * 12:
  12.             if name not in d.keys():
  13.                 d[name] = point
  14.             else:
  15.                 d[name] += point
  16.  
  17.     d_sorted = sorted(d.items(), key=lambda x: (-x[1],x[0]))
  18.  
  19.     print(d_sorted[0][0], d_sorted[0][1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement