Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import operator
- def exame1617_5():
- fich = open('input.txt','r+')
- fich2 = open('input2.txt','w')
- lista = []
- for line in fich.readlines():
- palavra = line.strip().split(' ')
- lista.append(palavra)
- for i in range(len(lista)):
- numero = lista[i][2]
- numeros = numero.strip().split(':')
- valor = int(numeros[0])*60*60 + int(numeros[1])* 60 + int(numeros[2])
- lista[i][2] = valor
- lista2 = sorted(lista,key = operator.itemgetter(2),reverse = False)
- for i in range(5):
- if i == 0:
- string = lista2[i][0] + ' ' + lista2[i][1] + ' ' + str(lista2[i][2]) + ' \n'
- fich2.write(string)
- else:
- valor = lista2[i][2] - lista2[0][2]
- string = lista2[i][0] + ' ' + lista2[i][1] + ' ' + str(valor) + ' \n'
- fich2.write(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement