# Stored variables:
#
# Last known block
# 10: version
# 11: hashPrevBlock
# 12: hashMerkleRoot
# 13: time
# 14: bits
# 15: nonce
# 16: blockHash / lastKnownBlock
# 17: score
#

def shared():
    TWO_POW_24 = 2 ^ 24

def init():
    self.storage[16] = 0x00000000000000000cfdd50d917943949fa708829ab70108c98cdb9f7d62339d

def code():
    return(-1)

def storeBlockHeader(version, hashPrevBlock, hashMerkleRoot, time, bits, nonce):
    exp = bits / TWO_POW_24
    mant = bits & 0xffffff
    target = mant * slt(1, (8*(exp - 3)))

def flipBytes(n):
    numByte = 32
    mask = 0xff

    result = 0
    i = 0
    while i < numByte:
        b = n & mask
        b /= 2^(i*8)
        b *= 2^((numByte-i-1)*8)
        mask *= 256
        result = result | b
        i += 1

    return(result)

# shift left
def slt(n, x):
    return(n * 2^x)

@@ -321,24 +321,48 @@
 def code():%0A
+    ret = self.slt(2,4)%0A
     return(-
@@ -360,18 +360,19 @@
  return(
--1
+ret
 )%0A%0Adef s
@@ -545,16 +545,17 @@
 - 3)))%0A%0A
+%0A
 def flip
@@ -833,16 +833,16 @@
 (n, x):%0A
-
     retu
@@ -853,8 +853,301 @@
  * 2%5Ex)%0A
+%0A%0Adef test():%0A    b1 = 0x0100000081cd02ab7e569e8bcd9317e2%0A    b2 = 0xfe99f2de44d49ab2b8851ba4a308000000000000e320b6c2fffc8d750423db8b%0A    b3 = 0x1eb942ae710e951ed797f7affc8892b0f1fc122bc7f5d74df2b9441a42a14695%0A    hash1 = sha256(%5Bb1,b2,b3%5D, 3)%0A    hash2 = sha256(%5Bhash1%5D, 1)%0A    return(hash2)%0A

trying to get the hash 1dbd981fe6985776b644b173a4d0385ddc1aa2a829688d1e0000000000000000