A modern & practical approach … (written in Go in this case, but any language will do)
package main
import (
"fmt"
"github.com/someone-else-who-has-done-all-the-work-already/fizzbuzz"
)
func main () {
fmt.Println( fizzbuzz(1,100) )
}
Its not cheating, and it does address the original intention of the FizzBuzz problem.
I think this is a valid solution, because (for better or for worse), the ability to collaborate with total strangers and existing solutions has become an important tool in the programmer’s arsenal,
Its also idiomatic Go (GoLang), to #include directly into a 3rd party github repo, support for which is built into the language from day 1. The compiler manages the fetching, building, regression testing of the 3rd party libs, as they change over time.
Given that the spec for FizzBuzz may well change over time … each time you compile this code, it may update itself automatically, and produce a different result ???
This has some wide philosophical implications when you dwell on that.
You can easily achieve the same thing in any toolchain by writing some extra lines in your Makefile or whatever. Go just sticks it right in your face and makes it obvious.
Is this what the customer actually asked for ? Nope !
Is this what the customer actually meant ? Probably !
Will asking the customer to clarify what they meant yield a correct answer ? Not very likely !