Boss lesson · Unit 01
A small codebase
Four files, one picture in your head
What you practise
- Four short files of one program: build the picture, answer what happens on an input, and find the one place a change belongs
Try a question from this lesson
Pick one
A parking garage program has four files. This is its entry point. Which other file is certainly on the path to the fee calculation?
# garage/: main.py report.py
# tickets.py rates.py
from report import summary
TICKETS = [("car", 61), ("bike", 10)]
print(summary(TICKETS))// garage/: main.js report.js
// tickets.js rates.js
import { summary } from "./report.js";
const TICKETS = [
["car", 61],
["bike", 10],
];
console.log(summary(TICKETS));// garage/: main.ts report.ts
// tickets.ts rates.ts
import { summary } from "./report";
const TICKETS: [string, number][] = [
["car", 61],
["bike", 10],
];
console.log(summary(TICKETS));Correct answer
report
Why
The entry point imports only the report module, so every fee has to be reached through it. Follow the imports and calls you can see before you guess from file names.
TypeScript note[string, number][] is an array of tuples: each ticket is exactly a kind and a number of minutes.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Draw the call map
After three functions you can draw the whole program: who calls whom. This map is your mental model.
With it, every question becomes a lookup. A wrong price per hour? The rates. Wrong rounding? The hours helper. A wrong total? The summary.
main
└─ report: summary
└─ tickets: fee
├─ rates: rate lookup
└─ tickets: hours10 more exercises in the app
- 3× type the answer
- 4× multiple choice
- 1× fill the blanks
- 1× true or false
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.