COIN = 100000000 def GetTotalBudget(nHeight): nSubsidy = 5 * COIN; # yearly decline of production by 7.1% per year, projected 21.3M coins max by year 2050. for i in range(210240, nHeight, 210240): nSubsidy -= nSubsidy/14 # Amount of blocks in a months period of time (using 2.6 minutes per) = (60*24*30)/2.6 return ((nSubsidy/100)*10)*576*30; def GetBudgetPaymentCycleBlocks(): # Amount of blocks in a months period of time (using 2.6 minutes per) = (60*24*30)/2.6 return 16616; def IsValidSuperBlock(nBlockHeight, nValue): if(nBlockHeight % GetBudgetPaymentCycleBlocks() < 100 and nValue <= GetTotalBudget(nBlockHeight)): return True else: return False def Test(nBlockHeight, nValue): if(IsValidSuperBlock(nBlockHeight, nValue)): print "nBlockHeight is a valid superblock - Block", nBlockHeight ," Cycle", nBlockHeight % GetBudgetPaymentCycleBlocks() return True else: print "nBlockHeight is not a valid superblock - Block", nBlockHeight ," Cycle", nBlockHeight % GetBudgetPaymentCycleBlocks() return False assert Test((16616*3), 400*COIN) == True assert Test((16616*3)+120, 4*COIN) == False #outside block range assert Test((16616*3)+3, 4000*COIN) == True assert Test((16616*3)+99, 4000*COIN) == True assert Test((16616*3)+101, 4000*COIN) == False #outside range assert Test((16616*3)+100, 9000*COIN) == False #outside range assert Test((16616*3)+100, 8000*COIN) == False #outside range assert Test((16616*48)+100, GetTotalBudget(16616*47)) == False assert Test((16616*48)+99, GetTotalBudget(16616*48)) == True assert Test((16616*48)+99, GetTotalBudget(16616*60)) == True assert Test((16616*48)+100, GetTotalBudget(16616*36)) == False print GetTotalBudget(16616*12) print GetTotalBudget(16616*24) print GetTotalBudget(16616*36) print GetTotalBudget(16616*48) print GetTotalBudget(16616*12*12) print GetTotalBudget(16616*12*24)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question