If a candidate were suggesting this as their serious FizzBuzz implementation fit for production, I'd have a hard talk with them about readability.
A way to torture an interviewer (C++, FizzBuzz)
11–20 of 84 posts
Re: A way to torture an interviewer (C++, FizzBuzz)
#12If a candidate were suggesting this as their serious FizzBuzz implementation fit for production, I'd have a hard talk with them about readability.
What implementation of FizzBuzz do you use in your production environment?
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
Re: A way to torture an interviewer (C++, FizzBuzz)
#13If a candidate were suggesting this as their serious FizzBuzz implementation fit for production, I'd have a hard talk with them about readability.
If an interviewer had a "hard talk" about anything during an interview, i'd have an immediate hard walk.
Re: A way to torture an interviewer (C++, FizzBuzz)
#14As someone who avoids C++ these days ... Is this a compile time FizzBuzz? `(char*)&1[""]` is the empty string here returning its data segment address as the offset? Not sure about the purpose of `1`. Is the iteration achieved by the constructor basically re-invoking itself?
Re: A way to torture an interviewer (C++, FizzBuzz)
#15If a candidate were suggesting this as their serious FizzBuzz implementation fit for production, I'd have a hard talk with them about readability.
What implementation of FizzBuzz do you use in your production environment?
In seriousness, the interview is supposed to give a taste of how the candidate thinks and codes in general. If they start using every obscure language feature under the sun, I am not too sure they got the idea.
Re: A way to torture an interviewer (C++, FizzBuzz)
#16As someone who avoids C++ these days ... Is this a compile time FizzBuzz? `(char*)&1[""]` is the empty string here returning its data segment address as the offset? Not sure about the purpose of `1`. Is the iteration achieved by the constructor basically re-invoking itself?
&1[""] is the same as &(""[1])
Re: A way to torture an interviewer (C++, FizzBuzz)
#17Re: A way to torture an interviewer (C++, FizzBuzz)
#18Re: A way to torture an interviewer (C++, FizzBuzz)
#19Yay, let's talk about FizzBuzz! This is the fastest PHP version I could come up with so far: I'm sure there still are ways to make it faster. But I fail to think of them. Except for unrolling multiple loops into one. But that is so ugly. Any ideas of elegant ways to make it faster? Testing the performance like this: php fizzbuzz.php | pv > /dev/null 215MiB/s on my slowish laptop. The "yes" command gives me about 10x…
Not sure I'd call writing Assembly "elegant" but hey!
Re: A way to torture an interviewer (C++, FizzBuzz)
#20As someone who avoids C++ these days ... Is this a compile time FizzBuzz? `(char*)&1[""]` is the empty string here returning its data segment address as the offset? Not sure about the purpose of `1`. Is the iteration achieved by the constructor basically re-invoking itself?
It's a static initialization time FizzBuzz. In this case, I think it's executed before main() is called, and not at compile time. Unless, of course, you have a very clever compiler that determines memory allocation is not actually allocating anything and that the output is a static string, and there are no side effects. Such a clever compiler could optimize it all into just one "puts" call.