IT/Software career thread: Invert binary trees for dollars.

Tuco

I got Tuco'd!
<Gold Donor>
45,451
73,541
FizzBuzz is easy if you're comfortable with modulus or doing your own modulus. I'd be surprised to ever see it in an interview just because most programming tests are puzzles which are worthless if the person knows the solution to the puzzle already.

Ohh god I love that. Had forgotten about it.
Fix code style violation reported in PR#184 ·[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */· GitHub

I just saw one of these code-reviews a few days ago
frown.png


LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL
Merge pull request #182 from joezeng/patch-1 ·[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */· GitHub
Man that brings back some bad memories of some software developers I work with who create voluminous amounts of code to solve very simple problems. They also do it because they 100% believe their way of producing code is superior. I feel like those developers are shit programmers who blindly apply programming methodologies because it's easier than solving the core issues.

I've seen code like the fizz buzz enterprise code and had conversations that went:

"Why did you make a class for doing while loops?"
"Because encapsulation is an important part of programming. You should read this book about data hiding so you can get to the next level of programming skill!"
"But you've taken a 5 line solution and made it into a 20 line solution."
"Maybe, but my solution is more testable. You should read this book about unit testing."
"But only because you added code, the core functionality has the same level of testability."
"Maybe, but with this you can exchange loops without knowing the underlying implementation. You should read this book about design patterns."

Ugh cargo cult programming.
 

Tuco

I got Tuco'd!
<Gold Donor>
45,451
73,541
Here is one using group theory. (c/c++)

#include <cstdio>

int main(){

const char *f[] = {
"%d", "%d", "Fizz", "%d", "Buzz", "Fizz", "%d", "%d",
"Fizz", "Buzz", "%d", "Fizz", "%d", "%d", "FizzBuzz",
};

for (int k = 0; k < 100; k++) {
printf(f[k % 15], k + 1);
printf("\n");
}

return 0;
}
I like this one but get nervous about overloading an argument list past the format specifier. I always ensure that my argument lists match the format exactly, because god help you if you put a float into a %d or any other combination.

Sometimes when administering programming tests you'll see candidates who want to be clever before they get the solution right. My recommendation is that everyone tries to do it in the most straightforward way possible.
 

Tenks

Bronze Knight of the Realm
14,163
606
Probably because after you've programmed professionally and shipped stuff to prod you understand maintainability and readability are two of the best ways to program and clever and short are not. I'm not saying sometimes a clever short line of code doesn't have a place in life but if you have to sit there for a minute to figure out what the fuck this line is supposed to do then at least add a comment or something to clarify.

I'm always aware wormie's was just a mental exercise
 

Asshat wormie

2023 Asshat Award Winner
<Gold Donor>
16,820
30,964
I like this one but get nervous about overloading an argument list past the format specifier. I always ensure that my argument lists match the format exactly, because god help you if you put a float into a %d or any other combination.

Sometimes when administering programming tests you'll see candidates who want to be clever before they get the solution right. My recommendation is that everyone tries to do it in the most straightforward way possible.
Well its guaranteed to work, always, because of math. Integers modulo 15 has two subgroups generated by [3] and [5]. The intersection of these sub groups is at [15] = [0]. Because of group properties, the code will work for all integers as long as we map the generators 3 and 5 to every third and fifth element in the array, and map 0 to the 15th element.

I like that particular solution to FizzBuzz because of a lack of conditionals.
 

Tenks

Bronze Knight of the Realm
14,163
606
Or in the interview claim Apache has released FizzBuzzUtils and your solution is

 

Deathwing

<Bronze Donator>
16,426
7,437
Probably because after you've programmed professionally and shipped stuff to prod you understand maintainability and readability are two of the best ways to program and clever and short are not. I'm not saying sometimes a clever short line of code doesn't have a place in life but if you have to sit there for a minute to figure out what the fuck this line is supposed to do then at least add a comment or something to clarify.

I'm always aware wormie's was just a mental exercise
This is why I dislike lambda functions. I'm still new to them, so maybe I need to work with them a bit more, but they almost always seem to add to code complexity while solving something mostly trivial.
 

Tenks

Bronze Knight of the Realm
14,163
606
In Lambda's defense anonymous inner functions just look horrible. I'm still trying to get used to them as well, though.
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
FizzBuzz is easy if you're comfortable with modulus or doing your own modulus. I'd be surprised to ever see it in an interview just because most programming tests are puzzles which are worthless if the person knows the solution to the puzzle already.



Man that brings back some bad memories of some software developers I work with who create voluminous amounts of code to solve very simple problems. They also do it because they 100% believe their way of producing code is superior. I feel like those developers are shit programmers who blindly apply programming methodologies because it's easier than solving the core issues.

I've seen code like the fizz buzz enterprise code and had conversations that went:

"Why did you make a class for doing while loops?"
"Because encapsulation is an important part of programming. You should read this book about data hiding so you can get to the next level of programming skill!"
"But you've taken a 5 line solution and made it into a 20 line solution."
"Maybe, but my solution is more testable. You should read this book about unit testing."
"But only because you added code, the core functionality has the same level of testability."
"Maybe, but with this you can exchange loops without knowing the underlying implementation. You should read this book about design patterns."

Ugh cargo cult programming.
Cargo cult programming is when u don't understand what you are doing, and just copy paste( like me doing angular js). On that example, that guy knew exactly what he was doing. He actually gave very good technical reason for his part. You just disagreed with his approach of over engineering, but that is not cargo cult programming.
 

Tuco

I got Tuco'd!
<Gold Donor>
45,451
73,541
Well its guaranteed to work, always, because of math. Integers modulo 15 has two subgroups generated by [3] and [5]. The intersection of these sub groups is at [15] = [0]. Because of group properties, the code will work for all integers as long as we map the generators 3 and 5 to every third and fifth element in the array, and map 0 to the 15th element.

I like that particular solution to FizzBuzz because of a lack of conditionals.
Yeah, I just would never want to be responsible for code that would sometimes call printf("fizzbuzz", 15); and sometimes call printf("%d", 2); or whatever.
 

Tuco

I got Tuco'd!
<Gold Donor>
45,451
73,541
Cargo cult programming is when u don't understand what you are doing, and just copy paste( like me doing angular js). On that example, that guy knew exactly what he was doing. He actually gave very good technical reason for his part. You just disagreed with his approach of over engineering, but that is not cargo cult programming.
I don't really agree with this. Cargo cults started because natives would see cargo planes drop supplies on marked locations. So they would then remark locations in their fucked up way.

If you were to ask a native, "why are you building this marking?" they would reply, "Because that's how you get supplied from plane gods. You should read this book on worship.".

When you take a concept, ex: function encapsulation, don't understand it well enough to use it properly, then inappropriately use it and cite the benefits of data encapsulations, you're participating in cargo cult programming.

But maybe I'm misusing the term!
 

Asshat wormie

2023 Asshat Award Winner
<Gold Donor>
16,820
30,964
Yeah, I just would never want to be responsible for code that would sometimes call printf("fizzbuzz", 15); and sometimes call printf("%d", 2); or whatever.
I find your lack of faith (in math) disturbing.
 

Vinen

God is dead
2,783
490
Probably because after you've programmed professionally and shipped stuff to prod you understand maintainability and readability are two of the best ways to program and clever and short are not. I'm not saying sometimes a clever short line of code doesn't have a place in life but if you have to sit there for a minute to figure out what the fuck this line is supposed to do then at least add a comment or something to clarify.

I'm always aware wormie's was just a mental exercise
And half the time there is no value in shortening the code as the compiler optimizes it...

I can't count the time I've screamed WHAT THE FUCK when debugging a customer issue and found it was some junior engineers science project that caused an escalation.
 

Tuco

I got Tuco'd!
<Gold Donor>
45,451
73,541
I find your lack of faith (in math) disturbing.
Not sure what you mean. I think I don't understand how math (or the modulus operate) relates to me not wanting to underspecify the format of the argument list I pass to variable argument functions.

I just would just be annoyed by the execution of this code:
printf("fizz", 3);
 

Cad

<Bronze Donator>
24,489
45,418
And half the time there is no value in shortening the code as the compiler optimizes it...

I can't count the time I've screamed WHAT THE FUCK when debugging a customer issue and found it was some junior engineers science project that caused an escalation.
I always had fun when someone called me to look at something, and had some like 6 class monstrosity to do something simple, and I deleted their shit from source control and re-did it with like 2 functions and 30 lines of code.

They'd be all "But it's not extensible!" ... but it took 20 minutes. Shut the fuck up and go write some easy to read, quick stuff that follows the requirements. Don't build me the Louvre when we need a lemonade stand.
 

Asshat wormie

2023 Asshat Award Winner
<Gold Donor>
16,820
30,964
Not sure what you mean. I think I don't understand how math (or the modulus operate) relates to me not wanting to underspecify the format of the argument list I pass to variable argument functions.

I just would just be annoyed by the execution of this code:
printf("fizz", 3);
I guess i was just not sure why you had an issue with it. The proper values will ALWAYS be passed to the function and the proper value in the domain (the array) will be mapped to. Which is due to the structure of the input and output we are using.
 

Tenks

Bronze Knight of the Realm
14,163
606
Yeah I certainly need to read up and learn Lambda. I feel like it should come fairly quickly since they resemble closures pretty heavily in Groovy. Like I'm dicking around with Spark and I can write the inner functions as Lambdas or anonymous inner classes and I'd prefer the previous route.
 

Tenks

Bronze Knight of the Realm
14,163
606
Had a phone interview with engineering at that company I was talking about and pretty sure I took myself out of the running by saying "I like to work 9-5 40 hours" when he asked if I'm adverse to staying at the office until 7 or 8. Not that I wouldn't when required but he framed it in the manner that lead me to think they may have a crunch week once a month. Working that much may be fine if I lived downtown or if I didn't already have a family and established career. But these days give me the benefits, the guaranteed work week and the vacation.
 

Vinen

God is dead
2,783
490
Had a phone interview with engineering at that company I was talking about and pretty sure I took myself out of the running by saying "I like to work 9-5 40 hours" when he asked if I'm adverse to staying at the office until 7 or 8. Not that I wouldn't when required but he framed it in the manner that lead me to think they may have a crunch week once a month. Working that much may be fine if I lived downtown or if I didn't already have a family and established career. But these days give me the benefits, the guaranteed work week and the vacation.
Lol staying into the office till 7 or 8?

Sounds like you dodged a bullet.

Once a munch Crunch? Sounds like Agile with 4 week sprints!