Math for Algorithms
Not school mathematics. Every idea arrives because a real program needed it: you work it by hand on concrete numbers, trace it step by step, and only then write it in JavaScript/TypeScript and Kotlin. The goal isn't memorizing formulas — it's looking at `PALETTE[count % PALETTE.length]` and knowing exactly why it works.
Part 1 · Numbers as programming tools
5 / 5 availableCounting, indexing, division and the single most reused expression in all of programming: n % size.
Part 2 · Arrays and index mathematics
8 / 8 availableWhy indexes start at zero, off-by-one errors, traversal in both directions, and rotating an array.
Part 3 · Counters and accumulators
7 / 7 availableRunning totals, averages, min/max, occurrence counts and balances — the loop patterns behind every dashboard.
Part 4 · Boolean math and conditions
7 / 7 availableEven/odd, divisibility, truth tables, De Morgan, and how to simplify a condition nobody can read.
Part 5 · Ranges
6 / 6 availableClamping, percentages, ratios, mapping one range onto another, and linear interpolation.
Part 6 · Coordinate mathematics
6 / 6 availableDeltas, distance, bounding boxes, collision and keeping a dragged object inside its container.
Part 7 · Algorithmic patterns
8 / 8 availableFrequency counters, two pointers, sliding windows and prefix sums — derived from brute force, not memorized.
Part 8 · Powers and growth
7 / 7 availablePowers of two, binary, bits, masks, permission flags and exponential backoff.
Part 9 · Search and logarithmic thinking
5 / 5 availableLinear search, binary search drawn half by half, and what O(log n) actually feels like.
Part 10 · Sorting
9 / 9 availableCompare, swap, selection and insertion for understanding, then divide-and-conquer with merge sort — plus bubble sort and quicksort.
Part 11 · Recursion
7 / 7 availableBase cases, the call stack drawn frame by frame, factorial, Fibonacci and why the naive version collapses.
Part 12 · Time and scheduling
5 / 5 availableSeconds to h:m:s, clock arithmetic, countdowns, repeating intervals and time windows.
Part 13 · Backend mathematics
8 / 8 availablePagination, offsets, batching, round-robin, rate limits, backoff, hash buckets and sharding.
Part 14 · Frontend mathematics
7 / 7 availableProgress, scroll percentage, aspect ratios, animation interpolation, drag math and index → row/column.
Part 15 · Complexity
7 / 7 availableCount the operations first, then name the curve. O(1), O(n), O(n²), O(log n), O(n log n), time vs space.
Part 16 · Problem solving
12 / 12 availableRead it, solve it by hand, find the pattern, write pseudocode, translate it twice, then break your own assumptions.
- 101. Read the problem correctly
- 102. Identify inputs and outputs
- 103. Solve it by hand first
- 104. Create your own examples
- 105. Find the pattern
- 106. Write pseudocode
- 107. Translate pseudocode into JavaScript
- 108. Translate the same algorithm into Kotlin
- 109. Find the edge cases
- 110. Test your assumptions
- 111. Improve a brute-force solution
- 112. Explain your own algorithm
Part 17 · Memory, lists and hash tables
5 / 5 availableHow memory actually stores an array, arrays vs linked lists, hash functions, collisions and load factor.
Part 18 · Graphs and shortest paths
5 / 5 availableGraphs as data, breadth-first search, weighted edges and Dijkstra's algorithm.
Part 19 · Trees
4 / 4 availableTrees as nested data, binary search trees, traversal orders and why balance decides performance.
Part 20 · Strategies: greedy, DP, and k-NN
6 / 6 availableGreedy choices and when they fail, dynamic programming tables, and classifying with k-nearest neighbours.
Part 21 · Correctness: proof, invariants and modelling
4 / 4 availableWhy passing tests is not the same as being right, induction and loop invariants, and the skill that decides everything — recognising your problem as one somebody already solved.
Part 22 · Heaps, priority queues and union-find
4 / 4 availableThe two data structures that make later algorithms possible: a queue that always hands you the smallest thing, and a structure that answers "are these two connected?" almost instantly.
Part 23 · Graphs, deeper
7 / 7 availableDirected graphs and cycles, topological order, components, minimum spanning trees with Prim and Kruskal, flow and matching — and the lesson that ties them together: model the graph, then reuse an algorithm.
Part 24 · Combinatorial search
5 / 5 availableBacktracking as one idea that generates every subset, permutation and Sudoku solution — then pruning, which is the only reason it finishes.
Part 25 · Dynamic programming, deeper
5 / 5 availableLongest increasing subsequence, longest common subsequence and partitioning — then how to recognise a DP problem on sight, and the shapes where DP simply does not apply.
Part 26 · Intractability, and what to do about it
6 / 6 availableReductions, satisfiability and P versus NP explained without hand-waving — how to tell a problem is hard, what to ship when it is, and a closing checklist for designing any algorithm.