Live data from Hacker News

A way to torture an interviewer (C++, FizzBuzz)

news.ycombinator.com

51–60 of 84 posts

Re: A way to torture an interviewer (C++, FizzBuzz)

#51

I’d walk out. Never, ever take a job given to you for solving a riddle. Everyone else there will have gotten theirs the same way and it won’t be great.

I mean I would even consider fizzbuzz a riddle. It’s one of the simplest programming tasks I have ever been asked in a technical assessment. Do you have a preferred alternative?

Re: A way to torture an interviewer (C++, FizzBuzz)

#52
post #2

If a candidate were suggesting this as their serious FizzBuzz implementation fit for production, I'd have a hard talk with them about readability.

Enterprise FizzBuzz or go home!

Realistically this is an appropriate joke answer to a joke question.

Re: A way to torture an interviewer (C++, FizzBuzz)

#54
post #38

Earlier quoted context omitted.

Ah, so it's the nil address?

No, it's the address past the end of the array {'\0'}.

Mind to unpack that for me?

Here's how I unpack this: ""[1] is the 0 (termination) byte. The 0 byte is then interpreted as an address -- the nil address.

But what's the use of asking for the address of the null terminator? Where is that stored exactly?

Re: A way to torture an interviewer (C++, FizzBuzz)

#55
This is undefined behavior. According to the C++ standard, there is no way to reason about what this does. Anything can happen with this code.

Once you have undefined behavior, you lose the ability to reason about your entire program.

Thus, this program does not solve the problem.

It demonstrates a lack of knowledge about undefined behavior in C++.

Rating: Absolutely would never hire this candidate.

Re: A way to torture an interviewer (C++, FizzBuzz)

#57
post #18

Earlier quoted context omitted.

The address of the nil byte + 1

But isn't `""` 0 terminated? So the first offset past the nil byte is 0, interpreted as an address.

"" is empty, so ""[0] is the nil byte.

The code uses "" as an arbitrary address, and ""[1] as that address + 1.

This way this-"" gets you 1-based index into the array.

It assumes the compiler dedfuplicates strings, making the behavior of this program undefined.

Re: A way to torture an interviewer (C++, FizzBuzz)

#59
post #44

Earlier quoted context omitted.

How much structure can a fizzbuzz have exactly?

How much structure would you like? https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

shudder

Sometimes I wonder why some dev teams take 10x longer to develop some functionality than what I would consider reasonable.

Then I see code like this.

Re: A way to torture an interviewer (C++, FizzBuzz)

#60

You wouldn't torture him. You would just zero the probability of getting an offer. There's no SW house or colleague in his right mind that would want a developer that writes obfuscated and needlessly complex to understand code.

Is consider this entertaining rather than torturous.

A playful response to the mind numbing idiocy of fizzbuzz.

Post reply on HN