nq1s788

24 максимальное 14ричное четное

May 13th, 2026
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. #Найти максимальное 14-ричное четное число
  2. s = open('24.txt').readline()
  3. S = s
  4. #alph = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  5. for e in 'EFGHIJKLMNOPQRSTUVWXYZ':
  6.     s = s.replace(e, '!')
  7. s = s.split('!')
  8. print(s[:100])
  9. a = []
  10. for e in s:
  11.     #if len(s) == 0:
  12.     #    continue
  13.     ind = -1
  14.     for i in range(len(e) - 1, -1, -1): #перебираем положительные индексы с конца
  15.     #for i in range(-1, -len(e)-1, -1): #перебираем отрицательные индексы с конца
  16.         if e[i] in 'AC02468':
  17.             ind = i
  18.             break
  19.     if ind != -1:
  20.         a.append(e[:ind+1])
  21. mx = '0'
  22. for e in a:
  23.     if int(e, 14) > int(mx, 14):
  24.         mx = e
  25. print(S.index(mx))
Advertisement
Add Comment
Please, Sign In to add comment