4 ms·
You wouldn't pass, because you didn't read the specs! "prints the numbers from 1 to 100." -- you printed 0-100! ;-) Just kidding, nice solution. Show's nicely
by kaeluka 15y ago
You wouldn't pass, because you didn't read the specs!
"prints the numbers from 1 to 100." -- you printed 0-100! ;-)
Just kidding, nice solution. Show's nicely how terrible and awesome the precompiler is.
- scott_s 15y agoThat's not actually the precompiler. The "precompiler" in C++ is the pre-processor, which just does straightforward text substitution. Template metaprogramming uses (abuses) the compiler itself. Templates in C++ are Turing Complete: http://netvor.sk/~umage/docs/3rdparty/C++%20Templates%20are%20Turing%20Complete.pdf http://netvor.sk/~umage/docs/3rdparty/C++%20Templates%20are%...
- kaeluka 15y agooh, sorry for the terminology glitch. Know about turing completeness, have used it for optimizing execution speed of programs and making TAs go insane.
- xanadohnt 15y agoUm, nope, it is within the spec. The spec doesn't mention not printing other numbers. He met the req of printing 1-100 (he just also happened to print 0).
- mkopinsky 15y agoBy this logic, the following would also be an acceptable solution: cat /dev/random > fizzbuzz.txt
- follower 15y ago> You wouldn't pass, because you didn't read the specs! > "prints the numbers from 1 to 100." -- you printed 0-100! ;-) This is specifically addressed in the "Exit Portability" section: "1. It starts at 0 instead of 1. This is just to make the output more readable by having the number encoded in the template argument (T0, T1, T2, etc) map directly to its FizzBuzz representation. If you want a strict version of FizzBuzz, just change the template specialization to terminate on '1' and return a vector<int_<1> > instead."
- philh 15y agoAlso gets 0 wrong. It should be a FizzBuzz.