Table of Contents
Month 1 · Week 1 — Exercises¶
Practice for syntax, types, control flow, and functions. Each folder is its own package with a solution and table-driven tests.
| Exercise | Concept | Day | Run tests |
|---|---|---|---|
fizzbuzz/ |
switch, modulo, slices | 004 | go test ./fizzbuzz |
temp-converter/ |
float math, conversions | 003 | go test ./temp-converter |
calculator/ |
multiple returns, error idiom | 005 | go test ./calculator |
How to use¶
- Try it yourself first — rename the solution aside and re-implement from the prompt below.
- Run
go test ./...from this directory. - Compare with the provided solution; log differences in your day note's "Mistakes" section.
Prompts¶
- FizzBuzz: return
"Fizz"/"Buzz"/"FizzBuzz"/the number for 1..n. Edge cases: order of checks (15 before ⅗), n=0. - Temperature converter: C↔F↔K. Watch operator precedence:
c*9/5 + 32. Add a round-trip test. - Calculator:
Apply(op, a, b)over+ - * /; returnErrDivByZeroon divide-by-zero and an error for unknown operators.
Tip: run all of Week 1 at once with
go test ./....