Updating functions
This commit is contained in:
parent
6b728695cb
commit
64e0295b26
7 changed files with 131186 additions and 5 deletions
23
CTPLICA/codes.py
Normal file
23
CTPLICA/codes.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
if __name__=='__main__':
|
||||
v1 = [i for i in range(256)]
|
||||
v2 = [i for i in range(256)]
|
||||
codes = []
|
||||
for e1 in v1:
|
||||
for e2 in v2:
|
||||
codes.append( (e1+e2,e1-e2) )
|
||||
#------
|
||||
for i in range(10):
|
||||
print(codes[i])
|
||||
#------
|
||||
unique_codes = []
|
||||
f = open('unique_codes.txt', 'w')
|
||||
for code in codes:
|
||||
if code not in unique_codes:
|
||||
f.write(str(code)+'\n')
|
||||
unique_codes.append(code)
|
||||
f.close()
|
||||
#------
|
||||
print('Total numbers of codes:', len(codes))
|
||||
print('Total numbers of unique codes:', len(unique_codes))
|
|
@ -401,8 +401,31 @@ def decode(code: str, size):
|
|||
for index in range(len(data)-1,-1,-1): result.append(data[index])
|
||||
return result
|
||||
|
||||
|
||||
|
||||
from math import cos
|
||||
def my_riddle():
|
||||
candidates_number = 0
|
||||
dig1 = int(str( eval('cos('+'1425100)') ).split('.')[1][5])
|
||||
dig2 = int(str(eval( '23*(1425100**2)-27*(1425100)+5' ))[3])
|
||||
for X in range(510):
|
||||
for Y in range(X+1):
|
||||
Xt = str(X)
|
||||
Yt = str(Y)
|
||||
if X < 10: Xt = '00'+str(X)
|
||||
elif X < 100: Xt = '0'+str(X)
|
||||
if Y < 10: Yt = '00'+str(Y)
|
||||
elif Y < 100: Yt = '0'+str(Y)
|
||||
if eval('1'+good_format(Xt+Yt)+'%23') == 20 and (int(str( eval('cos('+'1'+good_format(Xt+Yt)+')') ).split('.')[1][5]) + int(str(eval( '23*('+'1'+good_format(Xt+Yt)+'**2)-27*('+'1'+good_format(Xt+Yt)+')+5' ))[3])) ==(dig1+dig2): print('1'+Xt+Yt); candidates_number += 1
|
||||
#if eval('((((('+good_format(Xt+Yt)+'/255'+')%755127.255)%377563)%188781)%94390)%23') == 3: print(Xt+Yt); candidates_number += 1
|
||||
#if round(eval('((((('+'1503241/23'+')%755127)%377563)%188781)%94390)%23')) == 15: print(Xt+Yt); candidates_number += 1
|
||||
"""mysum = 0
|
||||
number_ = eval('1'+good_format(Xt+Yt))
|
||||
while number_!=0:
|
||||
mysum = mysum + eval('(number_%10)**len(str(number_))')
|
||||
number_ = (number_-(number_%10))//10
|
||||
if (1510255-mysum)%23==2: print(Xt+Yt); candidates_number += 1"""
|
||||
#if int(str( eval('cos('+'1'+good_format(Xt+Yt)+')') ).split('.')[1][4])==dig: print(Xt+Yt); candidates_number += 1
|
||||
#print('1'+good_format(Xt+Yt))
|
||||
print("candidates_number", candidates_number)
|
||||
|
||||
if __name__=='__main__':
|
||||
#print("add", sb_addition("2222222222222222222222222222222222222222.55", "2.55") )
|
||||
|
@ -426,6 +449,7 @@ if __name__=='__main__':
|
|||
#print(sb_division('22','7', digits_after_decimal_point=15))
|
||||
#print(sb_multiply('100000.00000','-0111111.0001'))
|
||||
#print(unoverlap('132.1230010'))
|
||||
c = encode(['2.55','1.27','0.50','0.25','0.01','1.27','0','0.78','0.99','0.54','2.31','2.55','1.27','0.50','0.50','0.50'])
|
||||
print("c",c)
|
||||
print(decode(c, size=16))
|
||||
#c = encode(['2.55','1.27','0.50','0.25','0.01','1.27','0','0.78','0.99','0.54','2.31','2.55','1.27','0.50','0.50','0.50'])
|
||||
#print("c",c)
|
||||
#print(decode(c, size=16))
|
||||
my_riddle()
|
65536
CTPLICA/formatted_codes.txt
Normal file
65536
CTPLICA/formatted_codes.txt
Normal file
File diff suppressed because it is too large
Load diff
11
CTPLICA/mydraft.py
Normal file
11
CTPLICA/mydraft.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
if __name__=='__main__':
|
||||
possible = 0
|
||||
for a in range(256):
|
||||
for b in range(256):
|
||||
#if a<b and a%2==1 and a>=127+b:
|
||||
if a%2==1 and b%2==0 and (a-b)>=0 and (a+b)<255 and (a-b)<127 and int(str(eval('a+b'))[0])>=3 and len(str(eval('a-b')))>=2 and len(str(eval('a+b')))>=2:
|
||||
print("a,b",a,b)
|
||||
possible += 1
|
||||
print(possible, "matches found")
|
0
CTPLICA/primes.txt
Normal file
0
CTPLICA/primes.txt
Normal file
51
CTPLICA/statistics.py
Normal file
51
CTPLICA/statistics.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import matplotlib as plt
|
||||
|
||||
def good_format(result: str) -> str:
|
||||
# order of following instructions is very important
|
||||
while result.startswith('0') and len(result)>=2 and result[1] != '.': result = result[1:]
|
||||
while result.startswith('-0') and len(result)>=3 and result[2] != '.': result = result.replace('-0','-')
|
||||
if '.' in result and result.split('.')[1]=='0'*len(result.split('.')[1]): result = result.split('.')[0]
|
||||
while '.' in result and result.endswith('0'): result = result[:-1]
|
||||
return result
|
||||
|
||||
|
||||
n_visu = 20
|
||||
if __name__=='__main__':
|
||||
#start generating codes
|
||||
v1 = [i for i in range(256)]
|
||||
v2 = [i for i in range(256)]
|
||||
codes = []
|
||||
for e1 in v1:
|
||||
for e2 in v2:
|
||||
codes.append( (e1+e2,e1-e2) )
|
||||
#format codes
|
||||
formatted_codes = []
|
||||
#f = open('formatted_codes.txt', 'w')
|
||||
for code in codes:
|
||||
current_code = ''
|
||||
#arranging to have 3 digits for each element in tuple
|
||||
X = str(code[0])
|
||||
Y = str(abs(code[1])) #to avoid converting the negative sign into string
|
||||
if code[0] < 10: X = '00'+X
|
||||
elif code[0] < 100: X = '0'+X
|
||||
if abs(code[1]) < 10: Y = '00'+Y
|
||||
elif abs(code[1]) < 100: Y = '0'+Y
|
||||
#creating current formatted code
|
||||
if code[1] < 0: #e1-e2<0
|
||||
current_code += '1'+X+Y
|
||||
else:
|
||||
current_code += '0'+X+Y
|
||||
#visualization purpose
|
||||
if n_visu>0:
|
||||
print("X", X, "Y", Y, "formatted code:", current_code)
|
||||
n_visu -= 1
|
||||
#put current code into formatted_codes and file
|
||||
formatted_codes.append( current_code )
|
||||
#print("verification:", '1510255' in formatted_codes)
|
||||
#f.write(current_code+'\n')
|
||||
#f.close()
|
||||
#giving statistics
|
||||
print("Number of codes:", len(formatted_codes))
|
||||
print("Probability to choose a code:", 1.0/len(formatted_codes))
|
65536
CTPLICA/unique_codes.txt
Normal file
65536
CTPLICA/unique_codes.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue