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 fractions import Fraction as F
from math import isclose
import json
checks=[]
def ck(name,actual,expected):
assert actual==expected,(name,actual,expected)
checks.append(dict(case=name,actual=str(actual),expected=str(expected)))
def approx(name,actual,expected):
assert isclose(float(actual),expected,abs_tol=.005),(name,actual,expected)
checks.append(dict(case=name,actual=float(actual),expectedRounded=expected))
ck('Separate new-site initial gap before reserve',40000-25000,15000)
ck('Separate existing-operation funds after improvement cost',25000-15000,10000)
ck('Top-down household share assumption',100000*F(1,100),F(1000))
ck('Reachable pilot-response arithmetic conditional',2000*F(1,20),F(100))
ck('Reachable conditional sales not a forecast',100*500,50000)
ck('Channel reach union under specified half-first-channel overlap',2000+10000-1000,11000)
ck('Separate operating feasible jobs',min(60,45),45)
ck('Separate operating revenue',45*600,27000)
ck('Separate direct expense',45*350,15750)
ck('Separate operating profit',27000-15750-7000,4250)
ck('Separate operating receipts',27000*F(3,5),F(16200))
ck('Separate operating receivables',27000-16200,10800)
ck('Separate operating cash',16200-15750-7000,-6550)
ck('Separate closing cash',4000+16200-15750-7000,-2550)
ck('Qualified extra subcontracted jobs profit contribution',15*(600-500),1500)
ck('Subcontracted extra jobs current receipt per job',600*F(3,5),F(360))
ck('Subcontracted extra jobs worsen current cash',15*(360-500),-2100)
r=F(11,10);discount=lambda t:F(1)/r**t
deposit=-10000+10000*discount(2)
approx('Refundable deposit cash value effect',deposit,-1735.54)
approx('Reduced deposit recovery cash value effect',-10000+7000*discount(2),-4214.88)
annuity=sum(discount(t) for t in (1,2,3));recovery=5000*discount(3)
ck('Cumulative initial outlay',20000+5000,25000)
ck('Cumulative initial funding gap',25000-22000,3000)
base=-25000+10000*annuity+recovery
approx('Original three-year NPV',base,3625.09)
base8=-25000+8000*annuity+recovery
approx('Original lower-cash NPV',base8,-1348.61)
approx('Original NPV decline from lower annual cash',base-base8,4973.70)
approx('Original-date zero-NPV annual cash threshold',(25000-recovery)/annuity,8542.30)
delayed_annuity=sum(discount(t) for t in (2,3,4));delayed_recovery=5000*discount(4)
delayed=-25000+10000*delayed_annuity+delayed_recovery
approx('New one-year-delay NPV',delayed,1022.81)
ck('Delay moves all future inflows one period',10000*delayed_annuity+delayed_recovery,(base+25000)/r)
approx('Combined delay and lower annual cash NPV',-25000+8000*delayed_annuity+delayed_recovery,-3498.74)
approx('Delayed zero-NPV annual cash threshold',(25000-delayed_recovery)/delayed_annuity,9547.58)
ck('Delay with unchanged initial outlay retains funding gap',25000-22000,3000)
print(json.dumps(dict(passed=True,scope='Synthetic optional capstone numerical mechanisms; no actual investment advice, operating authority, independent review or learner competence',checks=checks)))