Fizz Buzz
Real-world version: Drum Pattern CalloutsThe statement here is our own: the same inputs, outputs and technique.
A drum teacher runs a counting drill. The class counts beats out loud from 1 up to beats, but two beat families get a spoken cue instead of a number:
- a beat whose number is a multiple of
3is called as"Tap" - a beat whose number is a multiple of
5is called as"Thud" - a beat that is a multiple of both families is called as
"TapThud" - every other beat is called by its own number, written in decimal with no padding
Return the list of callouts for the whole drill, one string per beat, in beat order. The returned list has exactly beats entries and the entry at position i describes beat i + 1.
Examples
Example 1
- Input
- beats = 4
- Output
- ["1", "2", "Tap", "4"]
Only beat 3 lands on a cue family, so the other three beats are spoken as plain numbers.
Example 2
- Input
- beats = 16
- Output
- ["1", "2", "Tap", "4", "Thud", "Tap", "7", "8", "Tap", "Thud", "11", "Tap", "13", "14", "TapThud", "16"]
Beat 15 belongs to both families, so its callout joins the two cues in that order; beats 6, 9 and 12 take the first cue and beat 10 takes the second.
Example 3
- Input
- beats = 1
- Output
- ["1"]
A one-beat drill produces a single callout, the number itself.
Constraints
- 1 <= beats <= 10^4
The signature
The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.
def drum_labels(beats: int) -> list[str]:public List<String> drumLabels(int beats)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 7 test cases: 7 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's