10
1
The Fizz Buzz problem is a very basic problem to solve that is used by some to weed out interviewees that don't know how to program. The problem is:
Set N = [0,100]
Set F = x in N where x % 3 == 0
Set B = x in N where x % 5 == 0
Set FB = F intersect B
For all N:
if x in F: print fizz
if x in B: print buzz
if x in FB: print fizzbuzz
if x not in F|B|FB print x
The object of this modification of the Fizz Buzz problem is to perform the above algorithm using C++ templates such that as few runtime operations are necessary as can be done.
You can reduce N to a smaller range if you need to in order to fit within TMP objects where necessary.
This isn't expected to be a "golf".
11You should say "Template Metaprogramming" rather than TMP, because most non-C++ people would have no idea what TMP is. – Chris Jester-Young – 2011-01-27T21:47:51.787
6"weed out interviewees that don't know how to program" I didn't know that the average programmer needs to know Template Metaprogramming. – Alexandru – 2011-01-27T21:51:53.053
1How do you define runtime operation? Assembler instruction? If so it might be a good idea to specify a compiler and platform so that there's no ambiguity. – sepp2k – 2011-01-27T21:53:07.507
Backing up ChrisJester-Young: Imo
TMP
is temporary; template isTPL
. – Titus – 2017-02-12T14:53:41.3837@Alexandru: He said that the fizzbuzz problem is used to "weed out...", not that solving the fizzbuzz problem using Template Metaprogramming is. – sepp2k – 2011-01-27T22:19:51.040
Maybe you should mention that for all other numbers you need to print the number? – JPvdMerwe – 2011-01-27T22:36:30.027
1
Possible duplicate of 1, 2, Fizz, 4, Buzz
– pppery – 2019-12-23T05:09:54.753