Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def genesis_block(e):
- x = e % 2
- a = int(e/2) + x
- n = 1
- b = a + 2*x + 2*n
- c = a*b
- d = math.floor(math.sqrt(c))
- return (e, n, d, x, a, b)
- def generateNRowsFromGenesis(e, rows=10):
- genesis = genesis_block(e)
- block = genesis
- if e % 2 == 0:
- offset = 2
- else:
- offset = 4
- print (block)
- for i in range(rows):
- e, n, d, x, a, b = block
- a = b
- b = b + (offset + 4 * (i + 1))
- c = a * b
- d = math.floor(math.sqrt(c))
- x = math.floor(math.sqrt( (d + n)**2 -c ) - n)
- block = (e, n, d, x, a, b)
- print (block)
- def generateNthRowFromGenesis(e, nth=1):
- genesis = genesis_block(e)
- e, n, d, x, a, b = genesis
- if e % 2 == 0:
- a = int(int(e/2) + 2 * (nth**2))
- b = int(int(e/2) + 2 * ((nth + 1)**2))
- else:
- a = int(int(e/2) + 1 + 4 * ( (nth * (nth - 1))/2 ))
- b = int(int(e/2) + 1 + 4 * ( (nth * (nth + 1))/2 ))
- c = a * b
- d = math.floor(math.sqrt(c))
- ee = c - d**2
- n = (a + b)/2 - d
- x = d - a
- print (e, n, d, x, a, b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement