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