Lawfare Group → Knowledge Institute → Lawfare Academy

Reproduce the worked examples

Copy the complete code below into a UTF-8 file named verify.py and run python verify.py with Python 3. It uses only the standard library and performs exact or rational synthetic calculations. It does not access a network or learner records. Assertions fail if the expected synthetic results change.

These checks verify the stated arithmetic and query behavior, not independent academic acceptance or production migration safety.

from math import isclose
import json
checks=[]
def check(name,condition):
 assert condition,name
 checks.append(name)
factor=sum(1/1.1**t for t in range(1,6))
base=-50000+8000*factor;changed=-50000+16000*factor
check('retained rollout net savings',10000-2000==8000)
check('retained simple payback',50000/8000==6.25)
check('five-year discounted value',isclose(base,-19673.705844732424,abs_tol=.00001))
check('changed benefits discounted value',isclose(changed,10652.588310535152,abs_tol=.00001))
check('higher maintenance payback',isclose(50000/7000,7.142857142857143))
check('internal contribution',45*(300-180)==5400)
check('qualified overflow contribution',15*(300-250)==750)
check('mixed contribution',45*(300-180)+15*(300-250)==6150)
check('overstated internal-margin slide',60*(300-180)-6150==1050)
check('changed overflow cost',45*(300-180)+15*(300-320)==5100)
check('unavailable capacity',45<60 and 60-45==15)
check('quantity versus nominal sales growth',isclose(120000/100000/1.1-1,1/11))
check('hire100',9000+40*100==13000)
check('outsource100',130*100==13000)
check('unconstrained redesign100',5000+70*100==12000)
check('feasible redesign70 plus outsource30',5000+70*70+130*30==13800)
check('review cost changed alternatives',13000+600==13600 and 13800+600==14400)
early=20000-25000-7000;final=early+30000
check('early cash balance',early==-12000)
check('gap to reserve',3000-early==15000)
check('late receipt cannot fund prior date',final==18000 and early<0)
check('deferral changes timing not final total',20000-(25000-15000)-7000==3000 and 3000+30000-15000==18000)
check('zero-reserve changed rule',0-early==12000)
check('complete pilot cost',5000+1000+2000==8000)
check('budget is not cost',8000-7000==1000)
check('revised evaluation cost',5000+1000+3000==9000)
check('separate hypothetical comprehension criteria',4/5==.8 and 2/5==.4)
check('five rubric categories total',5*6==30)
if __name__=='__main__':print(json.dumps(dict(passed=True,checks=checks,calculated=dict(annuityFactor=factor,baseNPV=base,changedNPV=changed,mixedContribution=6150,changedOverflowContribution=5100,earlyCash=early,reserveGap=15000,finalCash=final)),indent=2))

Related chapters