All academies

Practice

Coding Challenges

Solve OOP and NestJS-style problems in the browser. The judge compiles your TypeScript and runs assertions — earn XP for each solve.

easy+40 XP

Design a Counter class

Implement a `Counter` class with `inc()`, `dec()`, and `value()` methods. Start at 0. `dec()` must not go below 0.

ClassesSolve
easy+50 XP

Fix encapsulation on BankAccount

Make `balance` private. Expose `deposit(amount)`, `withdraw(amount)`, and `getBalance()`. Reject non-positive deposits and overdrafts by throwing Error.

EncapsulationSolve
easy+50 XP

Implement Animal → Dog inheritance

Create `Animal` with `name` and `speak()` returning `'...'`. `Dog` extends Animal and overrides `speak()` to return `name + ' woofs'`.

InheritanceSolve
easy+45 XP

Composition: Car has-a Engine

Implement `Engine.start(): string` returning `'vroom'` and `Car` that takes Engine in the constructor and delegates `start()`.

CompositionSolve
medium+70 XP

Polymorphic Notifier

Define `interface Notifier { notify(msg: string): string }`. Implement `EmailNotifier` and `SmsNotifier`. Export function `alertAll(notifiers: Notifier[], msg: string): string[]`.

PolymorphismSolve
medium+80 XP

Apply constructor Dependency Injection

Create `interface Mailer { send(to: string): string }`, `ConsoleMailer`, and `AuthService` that receives Mailer via constructor and `register(email)` calls mailer.send.

Dependency InjectionSolve
medium+80 XP

Refactor tight coupling

Refactor so `ReportService` depends on `interface Database { query(sql: string): string[] }` injected in the constructor. Provide `MemoryDatabase` returning `['ok']` for any query. `run()` returns db.query('select 1').

DISolve
medium+75 XP

Implement a Repository

Implement `UserRepo` with `save(id, name)` and `find(id)`. Then `UserService` with constructor(repo) and `register(id, name)` / `get(id)`.

Design PatternsSolve
hard+100 XP

Apply SRP — split the god class

Replace GodService with UserService.create(name), Mailer.send(to), and Audit.log(event). `pipeline(name, email)` should create user, send mail, log 'created:'+name, and return the user object.

SOLIDSolve
hard+90 XP

Factory-style provider

Write `createGreeter(prefix: string)` returning `{ greet(name: string): string }` that returns prefix + name. `appGreet` should use createGreeter('Hi ').

NestJSSolve

10 challenges available — more coming in the 250+ set.