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
import json
response=20000+100*40+100*20;assert response==26000
baseline=1000*(200-80)-60000;assert baseline==60000
assert 100*200==20000 and 100*80==8000 and 100*(200-80)==12000
assert 100*200-100*30==17000
def option(affected,repair=20000):
 accounts=900+affected;revenue=900*200+affected*180;direct=accounts*80;response=repair+4000+2000
 return dict(accounts=accounts,revenue=revenue,direct=direct,contribution=revenue-direct,response=response,profit=revenue-direct-60000-response)
none=option(0);seventy=option(70);forty=option(40)
assert none==dict(accounts=900,revenue=180000,direct=72000,contribution=108000,response=26000,profit=22000)
assert seventy==dict(accounts=970,revenue=192600,direct=77600,contribution=115000,response=26000,profit=29000)
assert forty==dict(accounts=940,revenue=187200,direct=75200,contribution=112000,response=26000,profit=26000)
assert seventy['profit']-none['profit']==70*(180-80)==7000
assert option(0,30000)['profit']==12000 and option(70,30000)['profit']==19000
def funding(cost,line=8000):
 cash=20000-cost;need=max(0,5000-cash)
 return dict(cashBeforeFunding=cash,reserveFundingNeed=need,committedLine=line,reserveGap=max(0,need-line))
assert funding(26000)==dict(cashBeforeFunding=-6000,reserveFundingNeed=11000,committedLine=8000,reserveGap=3000)
assert funding(36000)['reserveFundingNeed']==21000 and funding(36000)['reserveGap']==13000
assert funding(26000,0)['reserveGap']==11000
total=100;marked=80;reopened=20;nonreopened=marked-reopened;verified=50
assert verified<=nonreopened<=marked<=total
assert [F(x,total) for x in [marked,nonreopened,verified]]==[F(8,10),F(6,10),F(5,10)]
assert F(verified+10,total)==F(6,10) and verified+10<=nonreopened
assert F(40,total)==F(4,10)
# The retained companion's scheduling difference is a tradeoff,not an ethical verdict.
assert 20000-12000==8000
print(json.dumps(dict(passed=True,scope='Synthetic economics,dated funding and nested status arithmetic only; no ethics/legal/technical or observed-learner determination.',baselineProfit=baseline,transparent900=none,transparent970=seventy,changedChoice940=forty,baseFunding=funding(26000),costStressFunding=funding(36000),statusRates=dict(marked=.8,nonreopened=.6,verified=.5),networkAccess=False,learnerAccess=False),indent=2))

Related chapters