1---
2app_version: 0.1.0
3precision: 2
4form_title: Rent per Square Meter
5form_description: Compare apartments by price per square meter. Enter rent and size to find the best value.
6form_inputs: Rent A|rent_a{€}, Size A|size_a{m²}, Rent B|rent_b{€}, Size B|size_b{m²}, Rent C|rent_c{€}, Size C|size_c{m²}
7form_outputs: Price/m² A|price_a, Price/m² B|price_b, Price/m² C|price_c, Lowest price|min_price
8---
9# Rent per Square Meter
10// Which apartment offers the best value?
11
12# Apartment A
13rent_a = 800 €
14size_a = 65 m²
15price_a = rent_a / size_a
16
17# Apartment B
18rent_b = 950 €
19size_b = 75 m²
20price_b = rent_b / size_b
21
22# Apartment C
23rent_c = 1100 €
24size_c = 85 m²
25price_c = rent_c / size_c
26
27# Comparison
28avg_price = (price_a + price_b + price_c) / 3
29
30// Find best value (lowest price per m²)
31min_ab = min(price_a, price_b)
32min_price = min(min_ab, price_c)
33
34// Price differences, translated into money: what the per-m² gap would cost
35// for an apartment the size of A, so B's and C's rates are compared on the
36// same footing rather than as a bare €/m² number.
37diff_ab = abs(price_a - price_b) * size_a
38diff_ac = abs(price_a - price_c) * size_a
39
40# Results
41"Apartment A": {size_a} at {rent_a} = {price_a}
42"Apartment B": {size_b} at {rent_b} = {price_b}
43"Apartment C": {size_c} at {rent_c} = {price_c}
44
45"Average price/m²": avg_price
46"Lowest price/m²": min_price
47
48"A vs B, at A's size": diff_ab
49"A vs C, at A's size": diff_ac
50