Advertisement
anon3985

VQC + t

Dec 10th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.12 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. DEBUG = True # False or True
  10.  
  11. # Thanks to C-sharp anon, i didnt have to write them by hand :D
  12. RSA100c = 1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139
  13. RSA100a = 37975227936943673922808872755445627854565536638199
  14. RSA100b = 40094690950920881030683735292761468389214899724061
  15. RSA100d = 39020571855401265512289573339484371018905006900194
  16. RSA100e = 61218444075812733697456051513875809617598014768503
  17. RSA100f = 16822699634989797327123095165092932420211999031886
  18. RSA100n = 14387588531011964456730684619177102985211280936
  19. RSA100x = 1045343918457591589480700584038743164339470261995
  20. RSA100x_plus_n = 1059731506988603553937431268657920267324681542931
  21.  
  22. # Not used. Using d=int(math.floor(math.sqrt(c))) instead
  23. # Maybe check later if python not able to handle big number
  24. # But no reason so far
  25. def bigIntegerSqrt(bigint):
  26.     n = 0; p = 0
  27.     if bigint == 0 : return 0
  28.     high = bigint >> 1; low = 0
  29.  
  30.     while high > (low + 1):
  31.         n = (high + low) >> 1
  32.         p = n * n
  33.  
  34.         if bigint < p:
  35.             high = n
  36.         elif bigint > p:
  37.             low = n
  38.         else:
  39.             break
  40.  
  41.     if bigint == p:
  42.         return n
  43.     else:
  44.         return low
  45.  
  46.  
  47. def createTheEnd(path, theend, i_max=256, x_min=0, y_min=0, x_max=128, y_max=128):
  48.     global DEBUG
  49.     # Thanks to the other Anon, you saved me a lot of time :)
  50.     if DEBUG: print "Starting constructing TheEnd"
  51.     for i in range(0,i_max):
  52.         if DEBUG : print "Constructing for i=",i
  53.         for j in range(0,i):
  54.             # Variable computation
  55.             # using ; to compress the code
  56.             a = i - j ; b = i + j ; c = a * b ; odd = True if (c%2) == 1 else False
  57.             d = int(math.floor(math.sqrt(c))) ; e = c - (d**2) ; f = e - ((2 * d) + 1)
  58.             n = i - d ; x = d - a
  59.  
  60.             if odd :
  61.                 t = (x +2) / 2
  62.             else:
  63.                 t = (x +1) / 2
  64.             # TheEnd entry adding
  65.             if e not in theend.keys(): theend[e] = {}
  66.             if n not in theend[e].keys():
  67.                 theend[e][n] = []
  68.                 # Basic white coloring
  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(t)+":"+str(n)+":"+str(d)+":"+str(x)+":"+str(a)+":"+str(b)+"}")
  75.             theend[f][n-1].append("{"+str(f)+":"+str(n-1)+":"+str(t)+":"+str(d+1)+":"+str(x+1)+":"+str(a,)+":"+str(b)+"}")
  76.     if DEBUG: print "TheEnd has been constructed"
  77.  
  78.  
  79. def outputTheEnd(path, theend, i_max=256, x_min=-128, y_min=0, set_size=12, x_max=128, y_max=128):
  80.     global DEBUG
  81.     f = open(path+"output.csv", 'w')
  82.     img = Image.new('RGB', (300, 300), "black")
  83.     pixels = img.load() # create the pixel map
  84.     if DEBUG: print ".csv file opened & image base created"
  85.     for y in range(y_min, y_max):
  86.         for z in range(0, set_size):
  87.             for x in range(x_min, x_max):
  88.                 if (x in theend.keys()) and (y in theend[x].keys()) and len(theend[x][y]) > z:
  89.                     f.write(theend[x][y][z]+",")
  90.            
  91.                     values = theend[x][y][z][1:-1].split(":")
  92.  
  93.                     xx = int(values[3])
  94.                     a = int(values[4])
  95.                     b = int(values[5])
  96.                     pixels[x + x_max, y] = (xx * 255 / i_max, a * 255 / (i_max * 2), b * 255 / (i_max * 4))
  97.  
  98.                 else:
  99.                     f.write("{},")
  100.                     pass
  101.             f.write('\n')
  102.     if DEBUG: print "Image & .csv generation done"
  103.     f.close()
  104.     #img.show()
  105.     img.save(path+"output.bmp")
  106.  
  107. if __name__ == '__main__':
  108.     theend = {}
  109.     # To change accordingly to he folder where you want to save stuff
  110.     path = "~/"
  111.     createTheEnd(path, theend)
  112.     outputTheEnd(path, theend)
  113.     if DEBUG : print "Done!!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement