Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.9 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69f8c998d78ad3171a0713be Challenge 291: FizzBuzz Count 29 challenge-291

--description--

Given a start and end number, count the number of fizz and buzz appearances in the range (inclusive).

  • Numbers divisible by 3 count as a fizz.
  • Numbers divisible by 5 count as a buzz.
  • Numbers divisible by both 3 and 5 count as both a fizz and a buzz.

Return an object or dictionary with the counts in the format: { fizz, buzz }.

--hints--

fizz_buzz_count(1, 11) should return {"fizz": 3, "buzz": 2}.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_count(1, 11), {"fizz": 3, "buzz": 2})`)
}})

fizz_buzz_count(14, 41) should return {"fizz": 9, "buzz": 6}.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_count(14, 41), {"fizz": 9, "buzz": 6})`)
}})

fizz_buzz_count(24, 100) should return {"fizz": 26, "buzz": 16}.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_count(24, 100), {"fizz": 26, "buzz": 16})`)
}})

fizz_buzz_count(-635, -14) should return {"fizz": 207, "buzz": 125}.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_count(-635, -14), {"fizz": 207, "buzz": 125})`)
}})

fizz_buzz_count(-5432, 6789) should return {"fizz": 4074, "buzz": 2444}.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_count(-5432, 6789), {"fizz": 4074, "buzz": 2444})`)
}})

--seed--

--seed-contents--

def fizz_buzz_count(start, end):

    return start

--solutions--

def fizz_buzz_count(start, end):
    fizz = sum(1 for i in range(start, end + 1) if i % 3 == 0)
    buzz = sum(1 for i in range(start, end + 1) if i % 5 == 0)
    return {"fizz": fizz, "buzz": buzz}