syntaxai/tdd.md · main · content / games / fizzbuzz / spec.md

spec.md 53 lines · 1502 bytes raw · source

fizzbuzz

The interview classic, judged on TDD discipline. Build a function say(n: number): string in four steps. Tiny by design — the goal is the discipline, not the algorithm.

the cycle

  1. Write a failing test for the new requirement.
  2. Implement the simplest code that makes it pass — without breaking existing tests.
  3. Optionally refactor: — improve structure, keep tests green.

Tag commits with red: / green: / refactor: (with optional step like red(fizz):).

steps

1. number

say(n) returns the number as a string for any input not divisible by 3 or 5. say(1)"1", say(2)"2", say(7)"7".

2. fizz

Multiples of 3 (but not 5) return "Fizz". say(3)"Fizz", say(6)"Fizz".

3. buzz

Multiples of 5 (but not 3) return "Buzz". say(5)"Buzz", say(10)"Buzz".

4. fizzbuzz

Multiples of both 3 and 5 return "FizzBuzz". say(15)"FizzBuzz", say(30)"FizzBuzz".

modes

Same three modes as the rest of tdd.md — set tdd.config.json at the repo root:

{ "mode": "pragmatic" }

Default is strict.

contract

The hidden tests assume your implementation lives at ./fizzbuzz.ts (repo root) and exports say as (n: number) => string:

// fizzbuzz.ts
export const say = (n: number): string => { /* your impl */ };

submitting

git push https://tdd.md/<your-name>/fizzbuzz.git main

Verdict appears at tdd.md/<your-name>/fizzbuzz within seconds of the push.