1---
2app_version: 0.7.0
3precision: 2
4form_title: Quit Smoking Savings
5form_description: See how much you've saved since you quit smoking — and what that money could be worth if you invested it instead of just keeping the cash. Form enabled.
6form_inputs: #Quit date, Quit year|quit_year, Quit month|quit_month, Quit day|quit_day, #Habit & cost, Cigarettes per day (before)|cigarettes_per_day, Cigarettes per pack|cigarettes_per_pack, Price per pack|price_per_pack{€}, #Invest the savings, Annual interest rate|interest_rate{%}, Projection horizon (years)|horizon_years
7form_outputs: Quit date|quit_date_label, Days smoke-free|days_smoke_free, Cigarettes avoided|cigarettes_avoided, Money saved so far (cash)|money_saved, Money saved so far (invested)|invested_value_now, Projected value after horizon|invested_value_horizon
8form_plots: 1
9---
10# Quit Smoking Savings
11// How much have you saved since you quit — and what could that money be
12// worth if you invested it instead of leaving it in cash?
13
14# When you quit
15// A form field is a plain number, so the date is entered as year/month/day
16// and reassembled with date() — that still lets it update live against today.
17quit_year = 2026
18quit_month = 9
19quit_day = 2
20quit_date = date(quit_year, quit_month, quit_day)
21
22# Your old habit
23cigarettes_per_day = 15 // cigarettes smoked per day, before quitting
24cigarettes_per_pack = 20 // cigarettes per pack
25price_per_pack = 7.50 € // price per pack
26
27# Invest the savings?
28interest_rate = 4 % // annual return if the savings were invested instead
29horizon_years = 10 // how far to project the comparison chart
30
31# Calculations
32price_per_cigarette = price_per_pack / cigarettes_per_pack
33
34quit_date_label = dformat(quit_date, "dd.MM.yyyy")
35days_smoke_free = days(today, quit_date)
36weeks_smoke_free = days_smoke_free / 7
37
38// Cigarettes and cash saved so far (no interest — money just kept aside)
39cigarettes_avoided = days_smoke_free * cigarettes_per_day
40money_saved = cigarettes_avoided * price_per_cigarette
41
42// Savings rate — independent of days_smoke_free, so it still makes sense
43// on day 0
44money_saved_per_day = cigarettes_per_day * price_per_cigarette
45money_saved_per_week = money_saved_per_day * 7
46money_saved_per_month = money_saved_per_day * 30
47money_saved_per_year = money_saved_per_day * 365
48
49// Rough time regained — a commonly cited estimate is about 11 minutes of
50// life expectancy per cigarette (UK ONS, 2000)
51minutes_per_cigarette = 11 min
52life_regained = cigarettes_avoided * minutes_per_cigarette
53
54# If you invested it instead
55// Future value of a regular deposit `payment`, paid every period for `n`
56// periods, earning `rate` per period. At rate = 0 (e.g. "what if I don't
57// invest it") the closed-form formula below is 0/0 — undefined, not zero —
58// so that case is handled separately: with no interest, future value is
59// just the sum of the deposits.
60def fv_annuity(payment, rate, n):
61 if rate == 0:
62 return payment * n
63 return payment * (((1 + rate)^n - 1) / rate)
64
65monthly_rate = interest_rate / 12
66cash(month) = money_saved_per_month * month
67balance(month) = fv_annuity(money_saved_per_month, monthly_rate, month)
68
69// What the money saved so far would be worth, had it been invested from day
70// one — day-by-day, since days_smoke_free is a whole number and a fraction
71// of a month would make the monthly formula above dip below the plain cash
72// total for any period under one full month.
73daily_rate = interest_rate / 365
74invested_value_now = fv_annuity(money_saved_per_day, daily_rate, days_smoke_free)
75invested_gain_now = invested_value_now - money_saved
76
77// Projected values if you keep not smoking for the full horizon
78horizon_months = horizon_years * 12
79cash_horizon = cash(horizon_months)
80invested_value_horizon = balance(horizon_months)
81
82# Results
83"Quit date": quit_date_label
84"Today": dformat(today, "dd.MM.yyyy")
85"Days smoke-free": days_smoke_free
86"Weeks smoke-free": weeks_smoke_free
87
88"Cigarettes avoided": cigarettes_avoided
89"Money saved so far (cash)": money_saved
90"Money saved so far, if invested": invested_value_now
91"Extra gained by investing so far": invested_gain_now
92
93"Savings per week (rate)": money_saved_per_week
94"Savings per month (rate)": money_saved_per_month
95"Savings per year (rate)": money_saved_per_year
96
97"Life expectancy regained (approx.)": life_regained in d
98
99"Projected at the chosen horizon, cash only": cash_horizon
100"Projected at the chosen horizon, invested": invested_value_horizon
101
102At {cigarettes_per_day} cigarettes a day, that habit would have cost you {money_saved} by now — money that stayed in your pocket instead.
103
104# The picture
105// Cash savings vs. the same money invested, sampled out to the projection
106// horizon — this is the chart the form embeds (form_plots: 1). The step size
107// scales with the horizon so a large value here still stays a handful of
108// points instead of building a huge list.
109chart_points = 40
110chart_step = max(1, round(horizon_months / chart_points))
111months_list = range(0, horizon_months + 1, chart_step)
112cash_list = map(cash, months_list)
113invested_list = map(balance, months_list)
114scatter(months_list, ["Cash saved": cash_list, "Invested, compounded": invested_list], "Cash vs. investing the cigarette money", "Months", "€")
115