Tame the Traffic Light
Medium About 22 min Katabench Pro
Every state re-checks power and timer in its own nested block.
The full brief is part of Katabench Pro
Pro opens this kata's brief, its starter code and its grader. To see how the track works first, try Tame the Discount Engine, which is free.
How it is graded
Behavioral tests have to stay green while the grader measures complexity, nesting, method length, and duplication from your source.
What it practices
- Remove duplication
- Extract the shared shape of pasted blocks and keep the real differences visible.
- Guard clauses
- Flatten nesting with early returns so the happy path reads top to bottom.
Related katas
- Tame Loan Eligibility Medium Pro A branch pyramid decides loans; flatten it into bands and guards.
- Tame the Discount Engine Medium Free Untangle a copy-pasted discount calculator until every quality gate passes - without changing a single answer.
- Dedupe the Field Validators Easy Free Three fields, three identical validation blocks.
- Flatten the Null Checks Easy Free An address printer hiding at the bottom of four nested ifs.