Skip to content

Instantly share code, notes, and snippets.

@tomjakubowski
Created October 23, 2012 00:28
Show Gist options
  • Save tomjakubowski/3935855 to your computer and use it in GitHub Desktop.
Save tomjakubowski/3935855 to your computer and use it in GitHub Desktop.

FizzBuzz as a Service (FBaaS)

various implementations of FizzBuzz as a Service.

specification

a 'natural number' is a member of the set of positive integers {1, 2, 3, …}

response

all successful response bodies are in UTF-8 encoded JSON. all errors are 500s with empty body, or 404s as appropriate.

get FizzBuzz range

GET /fizzbuzz/a,b

given the natural number interval [a,b], respond with a string constructed as follows:

for each n in [a,b]:

  1. if n is evenly divisible by 3, append the string "Fizz".
  2. if n is evenly divisible by 5, append the string "Buzz".
  3. if n is evenly divisible by neither 3 nor 5, append n as a string.
  4. append a line-feed character "\n"

error if a > b or if either a or b is not a natural number

example request

GET /fizzbuzz/1,20

example response

"1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment