Advertisement
anon3985

Basic VQC Python

Dec 8th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.58 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # To launch the file : python <thisfile>.py
  5. # or ./<thisfile>.py with exec rigths given to the script
  6. from PIL import Image
  7. import sys, math
  8.  
  9. # Thanks to C-sharp anon, i didnt have to write them by hand :D
  10. RSA100c = 1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139
  11. RSA100a = 37975227936943673922808872755445627854565536638199
  12. RSA100b = 40094690950920881030683735292761468389214899724061
  13. RSA100d = 39020571855401265512289573339484371018905006900194
  14. RSA100e = 61218444075812733697456051513875809617598014768503
  15. RSA100f = 16822699634989797327123095165092932420211999031886
  16. RSA100n = 14387588531011964456730684619177102985211280936
  17. RSA100x = 1045343918457591589480700584038743164339470261995
  18. RSA100x_plus_n = 1059731506988603553937431268657920267324681542931
  19.  
  20. # Not used. Using d=int(math.floor(math.sqrt(c))) instead
  21. # Maybe check later if python not able to handle big number
  22. # But no reason so far
  23. def bigIntegerSqrt(bigint):
  24.     n = 0; p = 0
  25.     if bigint == 0 : return 0
  26.     high = bigint >> 1; low = 0
  27.  
  28.     while high > (low + 1):
  29.         n = (high + low) >> 1
  30.         p = n * n
  31.  
  32.         if bigint < p:
  33.             high = n
  34.         elif bigint > p:
  35.             low = n
  36.         else:
  37.             break
  38.  
  39.     if bigint == p:
  40.         return n
  41.     else:
  42.         return low
  43.  
  44.  
  45. def createTheEnd(path, theend, i_max=512, x_min=0, y_min=0, x_max=64, y_max=64):
  46.     # Thanks to the other Anon, you saved me a lot of time :)
  47.    
  48.     #img = Image.new( 'RGB', (abs(x_min)+x_max,abs(y_min)+y_max), "black") # create a new black image
  49.     img = Image.new('RGB', (1024, 1024), "black")
  50.     pixels = img.load() # create the pixel map
  51.     for i in range(0,i_max):
  52.         for j in range(0,i):
  53.             # Variable computation
  54.             # using ; to compress the code
  55.             a = i - j ; b = i + j ; c = a * b ; odd = True if (c%2) == 1 else False
  56.             d = int(math.floor(math.sqrt(c))) ; e = c - (d**2) ; f = e - ((2 * d) + 1)
  57.             n = i - d ; x = d - a
  58.  
  59.  
  60.             # Bitmap Coloring
  61.             base = (a + b) / a
  62.             primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149]
  63.            
  64.  
  65.             # TheEnd entry adding
  66.             if e not in theend.keys(): theend[e] = {}
  67.             if n not in theend[e].keys():
  68.                 theend[e][n] = []
  69.                 pixels[e,n] = (255,255,255)
  70.             if f not in theend.keys(): theend[f] = {}
  71.             if n-1 not in theend[f].keys(): theend[f][n-1] = []
  72.  
  73.             # CSV entry adding
  74.             theend[e][n].append("{"+str(e)+":"+str(n)+":"+str(d)+":"+str(x)+":"+str(a)+":"+str(b)+"}")
  75.             theend[f][n-1].append("{"+str(f)+":"+str(n-1)+":"+str(d+1)+":"+str(x+1)+":"+str(a,)+":"+str(b)+"}")
  76.     img.show()
  77.     img.save(path+"output.bmp")
  78.  
  79.  
  80. def outputTheEnd(path, theend, i_max=256, x_min=-64, y_min=0, set_size=12, x_max=64, y_max=64):
  81.     f = open(path+"output.csv", 'w')
  82.     for y in range(y_min, y_max):
  83.         for z in range(0, set_size):
  84.             for x in range(x_min, x_max):
  85.                 if (x in theend.keys()) and (y in theend[x].keys()) and len(theend[x][y]) > z:
  86.                     f.write(theend[x][y][z]+",")
  87.                 else:
  88.                     f.write("{},")
  89.             f.write('\n')
  90.     f.close()
  91.  
  92.  
  93. if __name__ == '__main__':
  94.     theend = {}
  95.     # To change accordingly to he folder where you want to save stuff
  96.     path = "~/"
  97.     createTheEnd(path, theend)
  98.     outputTheEnd(path, theend)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement