Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def file_to_array(filename):
- file = open(filename, "r")
- file_content = file.read()
- file.close()
- return list(map(str, file_content.strip().split("\n")))
- arr = file_to_array("ciagi.txt")
- # a)
- a = []
- for sig in arr:
- if sig.find("11") == -1:
- a.append(sig)
- # c)
- c = []
- for sig in arr:
- if len(sig) % 2 == 0:
- if sig[:len(sig) // 2] == sig[len(sig) // 2:]:
- c.append(sig)
- # b)
- def is_prime(x):
- for i in range(2, int(math.sqrt(abs(x)))+1):
- if x % i == 0:
- return False
- return True
- def prime_div(x):
- for i in range(2, int(math.sqrt(abs(x)))+1):
- if x % i == 0:
- return i
- return -1
- b = []
- for sig in arr:
- dec = int(sig, 2)
- pd = prime_div(dec)
- if is_prime(dec//pd):
- b.append(sig)
Advertisement
Add Comment
Please, Sign In to add comment