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.

"""Synthetic checkpoints for the retained business companion and new clinic.
No network, actual enterprise records, account access or learner data.
Separate subcases deliberately retain their distinct populations and assumptions.
"""
from fractions import Fraction as F
from math import ceil
import json
checks={}
def check(k,v):assert v,k;checks[k]=True
profit=15000-7000-4000;operating=9000-7000-4000;closing=8000+operating+5000
check('stock_flow_profit',profit==4000)
check('operating_cash_separate',operating==-2000)
check('financing_and_closing',closing==11000 and 15000-9000==6000)
check('extra_collection_not_new_earnings',closing+3000==14000 and 6000-3000==3000 and profit==4000)
check('founder_work_and_residual',3000+F(8000-3000,2)==5500 and F(8000-3000,2)==2500)
check('changed_founder_work',1500+F(8000-1500,2)==4750 and F(8000-1500,2)==3250)
contribution=80-35;initial=90+45
check('subscription_contribution',contribution==45)
check('subscription_initial_recovery',ceil(F(initial,contribution))==3 and 2*contribution-initial==-45)
check('changed_subscription',ceil(F(90+90,contribution))==4 and 2*contribution-180==-90)
capacity=lambda production,inspection,delivery:min(70,production,inspection,delivery)
check('binding_delivery',capacity(60,50,45)==45 and 45*120==5400)
check('wrong_stage_cost',capacity(80,50,45)==45 and (capacity(80,50,45)-45)*120-500==-500)
check('changed_delivery_exposes_inspection',capacity(60,50,55)==50 and (50-45)*120-500==100)
check('competitive_base',30*(500-300)==6000)
check('price_matching',35*(450-300)==5250 and 5250-6000==-750)
check('evidenced_process_alternative',35*(450-260)-500==6150 and 6150-6000==150)
check('dashboard_bookings',F(120-100,100)==F(1,5))
check('dashboard_accepted_output',80-80==0)
check('dashboard_collections',F(28000-32000,32000)==F(-1,8))
def repair(collection_rate):
 revenue=50*400;direct=50*180;fixed=6000;receipts=revenue*collection_rate
 return dict(revenue=revenue,contribution=revenue-direct,profit=revenue-direct-fixed,receipts=receipts,receivables=revenue-receipts,operatingCash=receipts-direct-fixed,closingCash=10000+receipts-direct-fixed-5000)
r=repair(F(3,5))
check('repair_full_ledger',r==dict(revenue=20000,contribution=11000,profit=5000,receipts=12000,receivables=8000,operatingCash=-3000,closingCash=2000))
check('repair_cash_profit_bridge',r['profit']-r['receivables']-5000==r['closingCash']-10000)
r80=repair(F(4,5));r50=repair(F(1,2))
check('repair_eighty_percent',r80['closingCash']==6000 and r80['receivables']==4000 and r80['profit']==5000)
check('repair_fifty_percent',r50['closingCash']==0 and r50['receivables']==10000 and r50['profit']==5000)
check('rubric_maximum',6*4==24)
print(json.dumps(dict(passed=True,checks=checks,scope='Independent fictional subcases only. No actual cash saving, tax treatment, legal exposure, customer retention or observed proficiency is established.'),indent=2))

Related chapters