fork(3) download
  1. txt_file = ['3 love', '6 computers', '2 dogs', '4 cats', '1 I', '5 you']
  2. sorted_file = sorted(map(str.split, txt_file), key=lambda t: int(t[0]))
  3. print(*(
  4. sorted_file[(n + 1) * (n + 2) // 2 - 1][1]
  5. for n in range(int((8 * len(sorted_file) + 1) ** .5 - 1) // 2)
  6. ))
Success #stdin #stdout 0.03s 9720KB
stdin
Standard input is empty
stdout
I love computers