Advertisement
stupid_pro

Untitled

Jun 9th, 2023
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.37 KB | None | 0 0
  1. # s = open("24_2419.txt").readline()
  2. # s = s.replace('A', ' ').replace('B', ' ')
  3. # max_len = 0
  4. # for i in s.split():
  5. #     max_len = max(max_len, len(i))
  6. # print(max_len)
  7. # print(max(len(c) for c in s.split()))
  8.  
  9. s = open('24_2427.txt').readline()
  10. c = m = s[0]
  11. for i in range(1, len(s)):
  12.     if s[i] < s[i - 1]:
  13.         c += s[i]
  14.         m = max(m, c, key=len)
  15.     else:
  16.         c = s[i]
  17. print(m)
  18.  
  19. s = open('24_1145.txt').readline()
  20. s = s.replace('D', 'D D')
  21. print(min(len(c) for c in s.split() if c[0] == 'D' and c[len(c) - 1] == 'D' and len(c) > 2))
  22.  
  23. s = open('24_1146.txt').readline()
  24. for c in 'ABCEF':
  25.     s = s.replace(c, ' ')
  26. s = s.split()
  27. print(min(len(c) for c in s))
  28.  
  29. s = open('24_2250.txt').readline()
  30. s = s.split('A')
  31. m = -10000
  32. for i in range(len(s) - 1):
  33.     sub = s[i] + "A" + s[i + 1]
  34.     m = max(m, len(sub))
  35. print(m)
  36.  
  37. s = open('24_2251.txt').readline()
  38. m = 0
  39. s = s.split('D')
  40. for i in range(len(s) - 2):
  41.     sub = s[i] + 'D' + s[i + 1] + 'D' + s[i + 2]
  42.     m = max(len(sub), m)
  43. print(m)
  44.  
  45. s = open('24_4602.txt').readline()
  46. s = s.replace('O', 'A').replace('C', 'B').replace('D', 'B')
  47. sub = 'BA'
  48. print(sub in s)
  49. while sub in s:
  50.     sub += 'BA'
  51. print(len(sub) // 2)
  52.  
  53. s = open('24_4642.txt').readline()
  54. s = s.replace('B', 'A').replace('2', '1')
  55. sub = 'A1' * 34
  56. print(sub in s)
  57. while sub in s:
  58.     sub += 'A1'
  59. print(len(sub) / 2)
  60.  
  61.  
  62. s = open('24_4643.txt').readline()
  63. s = s.replace('B', 'A').replace('2', '1')
  64. s = s.replace('11A', '*')
  65. s = s.replace('1', ' ').replace('A', ' ')
  66. print(max(len(c) for c in s.split()))
  67.  
  68. s = open('24_4546.txt').readline()
  69. s = s.replace('B', '*')
  70.  
  71. c = m = 0
  72. for i in range(0, len(s) - 2, 3):
  73.     sub = s[i] + s[i + 2]
  74.     if sub == "AA" or sub == "CC":
  75.         c += 1
  76.         m = max(m, c)
  77.     else:
  78.         c = 0
  79. c = 0
  80. for i in range(1, len(s) - 2, 3):
  81.     sub = s[i] + s[i + 2]
  82.     if sub == "AA" or sub == "CC":
  83.         c += 1
  84.         m = max(m, c)
  85.     else:
  86.         c = 0
  87. c = 0
  88. for i in range(2, len(s) - 2, 3):
  89.     sub = s[i] + s[i + 2]
  90.     if sub == "AA" or sub == "CC":
  91.         c += 1
  92.         m = max(m, c)
  93.     else:
  94.         c = 0
  95.  
  96. print(m)
  97.  
  98. # s = open('24_5171.txt').readline()
  99. # sub = 'CA'
  100. # while sub in s:
  101. #     sub += 'CA'
  102. # print(len(sub) / 2)
  103. # sub = 27 * 'CA'
  104. # print(sub in s)
  105.  
  106. s = open('24_2497.txt').readline()
  107. print(s.count('XVIII'))
  108.  
  109. s = open('24_223.txt').readline()
  110. print(s.count('TIK') + s.count('TOK'))
  111.  
  112. s = open('24_314.txt').readline()
  113. print(s.count('OCK') - s.count('STOCK'))
  114.  
  115. s = open('24_279.txt').readline()
  116. print(s.count('BOSS') - (s.count('JBOSS') + s.count('BOSSJ') - s.count('JBOSSJ')))
  117.  
  118. s = open('24_2498.txt').readline()
  119. while 'XIXIX' in s:
  120.     s = s.replace('XIXIX', 'XIX XIX')
  121. print(s.count('XIX'))
  122. c = 0
  123. for i in range(len(s) - 2):
  124.     if s[i] + s[i + 1] + s[i + 2] == 'XIX':
  125.         c += 1
  126. print(c)
  127.  
  128. s = open('24_2499.txt').readline()
  129. c = 0
  130. for i in range(len(s) - 3):
  131.     sub = s[i] + s[i + 1] + s[i + 2] + s[i + 3]
  132.     if sub == 'XXXX':
  133.         c += 1
  134. print(c)
  135.  
  136. s = open('24_2500.txt').readline()
  137. c = 0
  138. for i in range(len(s) - 3):
  139.     sub = s[i] + s[i + 2] + s[i + 3]
  140.     if sub == "GME":
  141.         c += 1
  142. print(c)
  143.  
  144. s = open('24_2501.txt').readline()
  145. c = 0
  146. for i in range(len(s) - 4):
  147.     sub = s[i] + s[i + 2] + s[i + 4]
  148.     if sub == 'AAA':
  149.         c += 1
  150. print(c)
  151.  
  152. c = 0
  153. with open('24_859.txt') as file:
  154.     for line in file:
  155.         if line.count('S') == line.count('X'):
  156.             c += 1
  157. print(c)
  158.  
  159. c = 0
  160. with open('24_587.txt') as file:
  161.     for line in file:
  162.         res = (line.count('B') - line.count('A')) / line.count('B')
  163.         if res > 0 and (res - 0.05) > 0.0001:
  164.             c += 1
  165. print(c)
  166.  
  167. c = 0
  168. with open('24_2502.txt') as file:
  169.     for line in file:
  170.         flag = 0
  171.         for j in range(len(line) - 3):
  172.             sub = line[j] + line[j + 2] + line[j + 3]
  173.             if sub == 'KGE':
  174.                 flag = 1
  175.         if flag:
  176.             c += 1
  177. print(c)
  178.  
  179. with open('24_2503.txt') as file:
  180.     c = 0
  181.     for line in file:
  182.         c_oao = 0
  183.         c_aoa = 0
  184.         for j in range(len(line) - 2):
  185.             sub = line[j] + line[j + 1] + line[j + 2]
  186.             if sub == 'OAO':
  187.                 c_oao += 1
  188.             elif sub == 'AOA':
  189.                 c_aoa += 1
  190.         if c_aoa > c_oao:
  191.             c += 1
  192. print(c)
  193.  
  194. s = open('24_1143.txt').readline()
  195. c = 0
  196. for i in range(len(s) - 6):
  197.     if s[i] == 'A' and s[i + 6] == 'F':
  198.         c += 1
  199. for i in range(len(s) - 7):
  200.     if s[i] == 'A' and s[i + 7] == 'F':
  201.         c += 1
  202. for i in range(len(s) - 8):
  203.     if s[i] == 'A' and s[i + 8] == 'F':
  204.         c += 1
  205. for i in range(len(s) - 9):
  206.     if s[i] == 'A' and s[i + 9] == 'F':
  207.         c += 1
  208. print(c)
  209.  
  210. s = open('24_836.txt').readline()
  211. c = 0
  212. for i in range(len(s) - 4):
  213.     if s[i] == s[i + 4] and s[i + 1] == s[i + 3]:
  214.         c += 1
  215. print(c)
  216.  
  217. s = open('24_2506.txt').readline().strip()
  218. d = {x: s.count(x) for x in sorted(set(s))}
  219. print(max(d))
  220. print(d.keys())
  221. print(d.values())
  222.  
  223. s = open('24_2509.txt').readline().strip()
  224. d = {x: s.count(x) for x in sorted(set(s))}
  225. print(max(d.values()) - min(d.values()))
  226.  
  227. s = open('24_2505.txt').readline().strip()
  228. d = {x: 0 for x in sorted(set(s))}
  229. for i in range(len(s) - 2):
  230.     if s[i] == s[i + 2]:
  231.         d[s[i + 1]] += 1
  232. print(max(d.values()))
  233.  
  234. s = open('24_2504.txt').readline().strip()
  235. d = {x: 0 for x in sorted(set(s))}
  236. c = 0
  237. for i in range(len(s) - 4):
  238.     if s[i] + s[i + 1] + s[i + 3] + s[i + 4] == 'CBBC':
  239.         d[s[i + 2]] += 1
  240.  
  241. with open('24_2508.txt') as file:
  242.     q = 0
  243.     q_max = 0
  244.     cur_line = ''
  245.     for line in file:
  246.         q = line.count('Q')
  247.         if q >= q_max:
  248.             q_max = q
  249.             cur_line = line
  250. cur_line = cur_line.strip()
  251. d = {x: cur_line.count(x) for x in sorted(cur_line)}
  252. print(min(d.values()))
  253. #'C': 22
  254.  
  255. ans = 0
  256. with open('24_2508.txt') as file:
  257.     for line in file:
  258.         ans += line.count('C')
  259. print('C', ans)
  260.  
  261. m, ms = 0, ''
  262. s1 = ''
  263. for s in open('24_2507.txt'):
  264.     s1 += s
  265.     m1 = c = s[0]
  266.     for i in range(1, len(s)):
  267.         if s[i - 1] == s[i]:
  268.             c += s[i]
  269.             m1 = max(m1, c, key=len)
  270.         else:
  271.             c = s[i]
  272.     if len(m1) > m:
  273.         m, ms = len(m1), s.strip()
  274.  
  275. d = {x: ms.count(x) for x in sorted(set(ms))}
  276. m = max(d.values())
  277. l = [i for i in d if d[i] == m]
  278. print(l, m)
  279. print(m, s1.count(l[0]))
  280.  
  281.  
  282.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement