Advertisement
stupid_pro

"5"

Jun 15th, 2023
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.59 KB | None | 0 0
  1. def f(n):
  2.     str_n = str(n)
  3.     first = int(str_n[0]) + int(str_n[1])
  4.     second = int(str_n[2]) + int(str_n[3])
  5.     return str(max(first, second)) + str(min(first, second))
  6.  
  7.  
  8. for i in range(1000, 10000):
  9.     if f(i) == "1512":
  10.         print(i)
  11.         break
  12.  
  13. def f(n):
  14.     bin_n = bin(n).removeprefix('0b')
  15.     if bin_n.count('1') % 2 == 0:
  16.         bin_n += '1'
  17.     else:
  18.         bin_n += '0'
  19.  
  20.     if bin_n.count('1') % 2 == 0:
  21.         bin_n += '1'
  22.     else:
  23.         bin_n += '0'
  24.  
  25.     return int(bin_n, 2)
  26.  
  27.  
  28. ans = []
  29. for i in range(1, 100000):
  30.     if f(i) > 54:
  31.         ans.append(f(i))
  32. print(ans[0])
  33.  
  34. def f(n):
  35.     bin_n = bin(n).removeprefix('0b')
  36.     for j in range(2):
  37.         if bin_n.count('1') % 2 == 0:
  38.             bin_n += '0'
  39.         else:
  40.             bin_n += '1'
  41.     return int(bin_n, 2)
  42. ans = []
  43. for i in range(1000):
  44.     if f(i) > 96:
  45.         ans.append(i)
  46. print(min(ans))
  47.  
  48. def f(n):
  49.     bin_n = bin(n).removeprefix('0b')
  50.     for j in range(2):
  51.         if bin_n.count('1') % 2 == 0:
  52.             bin_n += '0'
  53.         else:
  54.             bin_n += '1'
  55.     return int(bin_n, 2)
  56.  
  57. ans = []
  58. for i in range(1000):
  59.     if f(i) > 116:
  60.         ans.append(f(i))
  61. print(min(ans))
  62.  
  63. def f(x):
  64.     first = x % 4
  65.     second = x % 2
  66.     third = x % 3
  67.     return str(first) + str(second) + str(third)
  68.  
  69. for i in range(1000):
  70.     if f(i) == "311":
  71.         print(i)
  72.         break
  73.  
  74. def f(n):
  75.     str_n = str(n)
  76.     first = int(str_n[0]) + int(str_n[1])
  77.     second = int(str_n[1]) + int(str_n[2])
  78.     third = int(str_n[2]) + int(str_n[3])
  79.     ans = [first, second, third]
  80.     ans.sort()
  81.     ans.pop(0)
  82.     return str(ans[1]) + str(ans[0])
  83.  
  84.  
  85. a = []
  86. for i in range(1000, 10000):
  87.     if f(i) == '1414':
  88.         a.append(i)
  89. print(max(a))
  90.  
  91. def f(n):
  92.     bin_n = bin(n).removeprefix('0b')
  93.     for j in range(2):
  94.         if bin_n.count('1') % 2 == 0:
  95.             bin_n += '0'
  96.         else:
  97.             bin_n += '1'
  98.     return int(bin_n, 2)
  99.  
  100.  
  101. ans = []
  102. for i in range(1000):
  103.     ans.append(f(i))
  104. ans.sort()
  105. ans = [c for c in ans if 16 <= c <= 32]
  106. cntr = 0
  107. for i in range(16, 33):
  108.     if i not in ans:
  109.         cntr += 1
  110. print(cntr)
  111.  
  112. print(ans, 33 - 16 - 4)
  113.  
  114. def f(n):
  115.     bin_n = bin(n).removeprefix('0b')
  116.     if len(bin_n) < 8:
  117.         while len(bin_n) != 8:
  118.             bin_n = '0' + bin_n
  119.     new_str = ''
  120.     for i in range(len(bin_n)):
  121.         if bin_n[i] == '0':
  122.             new_str += '1'
  123.         else:
  124.             new_str += '0'
  125.     return int(new_str, 2)
  126.  
  127.  
  128. for i in range(256):
  129.     new = f(i)
  130.     if new - i == 99:
  131.         print(i)
  132.  
  133. def f(n):
  134.     str_n = str(n)
  135.     a, b, c = int(str_n[0]), int(str_n[1]), int(str_n[2])
  136.     arr = [a, b, c]
  137.     arr.sort()
  138.     big = int(str(arr[2]) + str(arr[1]))
  139.     small = int(str(arr[0]) + str(arr[1]))
  140.     if 9 < big < 100 and 9 < small < 100:
  141.         return big - small
  142.     else:
  143.         return 0
  144.  
  145.  
  146. cntr = 0
  147. for i in range(300, 401):
  148.     if f(i) == 20:
  149.         cntr += 1
  150. print(cntr)
  151.  
  152. def f(n):
  153.     str_n = str(n)
  154.     a = int(str_n[0]) + int(str_n[3])
  155.     b = int(str_n[1]) + int(str_n[2])
  156.     return str(max(a, b)) + str(min(a, b))
  157.  
  158. for i in range(1000, 10000):
  159.     if f(i) == '128':
  160.         print(i)
  161.         break
  162.  
  163. def f(n):
  164.     bin_n = bin(n).removeprefix('0b')
  165.     for i in range(2):
  166.         if bin_n.count('1') % 2 == 0:
  167.             bin_n += '0'
  168.         else:
  169.             bin_n += '1'
  170.     return int(bin_n, 2)
  171.  
  172.  
  173. ans = []
  174. for i in range(1, 1000):
  175.     if f(i) > 130:
  176.         ans.append(f(i))
  177. print(min(ans))
  178.  
  179.  
  180. def f(n):
  181.     str_n = str(n)
  182.     a = int(str_n[0]) + int(str_n[2]) + int(str_n[4])
  183.     b = int(str_n[1]) + int(str_n[3])
  184.     return int(str(min(a, b)) + str(max(a, b)))
  185.  
  186.  
  187. for i in range(10000, 100000):
  188.     if f(i) == 621:
  189.         print(i)
  190.  
  191. def f(x):
  192.     a, b, c = x % 4, x % 3, x % 2
  193.     s = str(a) + str(b) + str(c)
  194.     return int(s)
  195.  
  196. ans = []
  197. for i in range(10, 100):
  198.     if f(i) == 220:
  199.         ans.append(i)
  200. print(max(ans))
  201.  
  202. def f(n):
  203.     str_n = bin(n).removeprefix('0b')
  204.     if len(str_n) < 8:
  205.         while len(str_n) != 8:
  206.             str_n = '0' + str_n
  207.     new = ''
  208.     for i in range(len(str_n)):
  209.         if str_n[i] == '1':
  210.             new += '0'
  211.         else:
  212.             new += '1'
  213.     return int(new, 2)
  214.  
  215.  
  216. for j in range(0, 256):
  217.     k = f(j)
  218.     if k - j == -21:
  219.         print(j)
  220. 10001010 -> 01110101
  221.  
  222. def f(n):
  223.     str_n = bin(n).removeprefix('0b')
  224.     str_n = str_n[::-1]
  225.     str_n = str(int(str_n))
  226.     return int(str_n, 2)
  227.  
  228. ans = []
  229. for i in range(1, 101):
  230.     if f(i) == 7:
  231.         ans.append(i)
  232. print(max(ans))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement