Farz0l1x

Untitled

Dec 7th, 2023
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. def f(a, b, c):
  2.     B = [a, b, c]
  3.     count = 0
  4.     for i in range(len(B)):
  5.         if str(B[i])[:1] == '6':
  6.             count += 1
  7.     return count
  8. file = open('17_11460.txt')
  9. A = list(map(int, file.readlines()))
  10. Max8 = -10**9
  11. count = 0
  12. Min = 10**10
  13. for i in range(len(A)):
  14.     if str(A[i])[:1] == '8':
  15.         Max8 = max(Max8, A[i])
  16. for i in range(2, len(A)):
  17.     if f(A[i], A[i-1], A[i-2]) <= 1 and A[i] + A[i-1] + A[i-1] >= Max8:
  18.         count += 1
  19.         Min = min(Min, A[i] + A[i-1] + A[i-1])
  20. print(count, Min)
Advertisement
Add Comment
Please, Sign In to add comment