Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Задача 17 способ 1
- tf = open('17.txt')
- maxi = float('-inf')
- count = 0
- prev_x = int(tf.readline())
- for x in tf:
- x = int(x)
- pair = prev_x + x
- if prev_x % 3 == 0 or x % 3 == 0:
- count += 1
- maxi = max(pair, maxi)
- prev_x = x
- print(count, maxi)
- # Задача 17 способ 2
- a = [int(x) for x in open('17.txt')]
- count = 0
- maxi = -100000
- for i in range(1, len(a)):
- if a[i - 1] % 3 == 0 or a[i] % 3 == 0:
- count += 1
- maxi = max([a[i - 1], a[i], maxi])
- print(count, maxi)
- # Задача 24
- tf = open('24.txt')
- s = tf.readline()
- res = s[0]
- maxi = float('-inf')
- for i in range(1, len(s)):
- if s[i - 1] + s[i] != 'PP':
- res += s[i]
- maxi = max(maxi, len(res))
- else:
- res = s[i]
- print(maxi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement