5 ms·
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 develope
by thisiswrongggg 4y ago
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.
- aloisdg 4y agoWhat if the SW house is competing in the ioccc?
- astrange 4y agoQA engineer for a C++ compiler?
- leni536 4y agoThis program is undefined, so no, except maybe if you can make the compiler itself to crash.
- astrange 4y agoThat's a good thing to test. Btw, here's a C++ sample that crashes icc: https://pastebin.com/PiRtZi1t https://pastebin.com/PiRtZi1t. I haven't reported it because it's funnier this way.
- easytiger 4y agoUnless they had, and i know this is hard to imagine in a c++ dev, a sense of humour
- shultays 4y agoI mean the code also includes a bunch of undefined behaviors, we do not joke about that
- FpUser 4y agoI would not want developer to write this kind of code in production applications but I would very much hire a person who is capable of coming up with the code like this.
- dotancohen 4y agoThis whole point of Fizzbuzz is to see how one structures their code. Or at least ascertain that one _can_ write code in the first place.
- tpxl 4y agoHow much structure can a fizzbuzz have exactly?
- galoisgirl 4y agoYou can make it easily extendable for division by 7.
- arethuza 4y agoHow much structure would you like? https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
- trashtester 4y agoshudder 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.
- dotancohen 4y ago> How much structure would you like? top = 100 data = { 3: "fizz", 5: "buzz" } for i in range(1, top+1): output_num = True for j in data: if i%j == 0: print(data[j], end="") output_num = False if output_num: print(i) else: print("") This is enough structure to anticipate the inevitable customer changing the requirements. No magic numbers in the real code. Of course, I just banged this out in a web browser text editor. In PyCharm that better be wrapped in a function at minimum, or a module.
- vbezhenar 4y agoFizzbuzz is a pass to the next questions. It's a way to weed out random people who have no idea about programming but for some reason came to the interview. While this code wouldn't be an instant offer, it would be a great solution in my eyes and it would follow hardest questions to qualify a candidate for senior position. That's my opinion at least. I'm making a hiring decisions in my company.
- thechao 4y agoIt's a great way to tell jokes, loosen up the interviewee, and get the jitters out.
- oldgradstudent 4y agoIs consider this entertaining rather than torturous. A playful response to the mind numbing idiocy of fizzbuzz.
- arethuza 4y agoIf someone wrote that in an interview I'd be keen to get them to explain to me exactly how it works... my C++ being a bit rusty (I mean old).
- jpegqs 4y agoExplanation: 1. There are no data members inside X, in this case the size of the structure is 1 byte. 2. main() does nothing. 3. *x = new X[100]() - this requests a new array of 100 elements of type X, at a stage before main() is called. 4. The new[] operator is overloaded in the class, this operator must return the address for the requested array. It returns the address of the empty string object plus 1. 5. For each of the 100 elements, the X() constructor is called, the "this" address for those elements will be the value returned by new[] plus an index from 0 to 99. The X() constructor converts this to a number from 1 to 100 by subtracting the address of the empty string. This is the only UB here, but it works in all major modern compilers since they combine the same strings into one instance.
- leni536 4y ago> This is the only UB here. That's debateable. 1. new[] doesn't return a pointer that is suitable for storage for the objects. Yes the objects are empty (only contain padding), but that doesn't absolve from UB. 2. "" is used at two places, assuming that they refer to the same const char array. This is optimization is allowed, commonly implemented, but not guaranteed. 3. An empty struct having 1 byte size is also implementation defined, although common ABIs specify this. It also wouldn't make sense to implement it differently.
- shultays 4y agoSince new[] does not actually return an array (returns a pointer to 1-past-the last element in "" string/array) and later "this" pointer is calculated using an arithmetic operation that goes out of bounds (for elements that > 0), that would also be UB. ""+2 would be UB for example. But maybe it is not UB because it is not calculated explicitly by the program, hard to tell
- Akronymus 4y agoWould you deem this needlessly complex? https://try.fsharp.org/#?code=DYUwLgBAZglgXnARgVwRAdsgthAvAWACgISJRIATEAYxioCcIKYA3GAZwHtGYo4R6nCL3Scw-QRmx4ipORCwBDMNQAWUnAFImrDtwgB3GGFWz5JAD4QADBAC0APmF8BQzDjPmrAfXtORYhJu0p5k4BAoCAJ4EKFyVLQMEACsEAAUUMjoEAAefhAARABCqHAFAJSxxKTk0PASMtXmCXTRceYQAMxVHfIZWbn5BQBi9QUQANTpkQ392b6OhRW55eXt5nODi2kz0ZsAnvn7AHQAKpwAymD0MOgA5mmrg6uhsFGM7kRfhADaAIzHY5-ZLWAC6RAsTguIAAjsclAAHOoIGYQqGw47GPYIm7oMBQbIFTTsCpEIA&html=DwCwLgtgNgfAsAKAAQqaApgQwCb2ag4CdMTJcMABwFp0BHAVwEsA3AXgCIBhAewDsw6AdQAqAT0roOSAMb9BAzoIAeYAPThoAbhkhMAJwDOJNgzAAzagA4OeQhqy5EhAEY9sYu6mBq3HvD6asEA&css=Q https://try.fsharp.org/#?code=DYUwLgBAZglgXnARgVwRAdsgthAvAW...