Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def main():
  2.     with open('input.txt', mode='r') as f:
  3.         happy_ticket_count = 0
  4.         total_sum = 0
  5.         total_count = 0
  6.         for line in f:
  7.             s = line.rstrip()
  8.             s = list(map(float, s))
  9.             sum1 = sum(s[:3], 0)
  10.             sum2 = sum(s[3:], 0)
  11.             total_sum += sum1 + sum2
  12.             if sum1 == sum2:
  13.                 happy_ticket_count += 1
  14.             total_count +=1
  15.    
  16.     with open('output.txt', mode='a') as f:
  17.         f.write(str(happy_ticket_count)+'\n')
  18.         f.write((format((total_sum/(total_count*6)), '.2f')))
  19.  
  20. if __name__ == "__main__":
  21.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement