[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>at interview for java programming job >asks me to do the

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 112
Thread images: 8

File: download.png (7KB, 260x194px) Image search: [Google]
download.png
7KB, 260x194px
>at interview for java programming job
>asks me to do the "fizzbuzz" code test
>google "fizzbuzz java" and copy/paste result right infront of him
>congratz anon, you got the job

This is how easy it is to code.
>>
>>58964911
>things that didn't happen
>>
do you think this is a funny thread, op?
>>
I slightly chuckled
>>
>>58964911
But that's web development, not coding
>>
I literally had an interview today.

The problem was "Iterate through 100 to 0, and return the sum of all numbers divisible by 3 and all numbers divisible by 5."

I was the only one to ask "so this is a modified FizzBuzz, right?"
>>
>>58966520
>I was the only one to ask
What did he mean by this?
>>
>>58966520
You sound like a retard pointing out the obvious
>>
File: fizzbuzz.png (14KB, 638x224px) Image search: [Google]
fizzbuzz.png
14KB, 638x224px
>>58964911
Never tried fizzbuzz before, what am I missing why is this so hard?

I'm a sysadmin btw, so all I know is powershell and perl.
>>
>he thinks they give you a laptop
>he thinks you get auto suggestions in an IDE

lmao no you write that shit out
>>
>>58966851
FizzBuzz is a trivial question that helps interviewers weed out non-programmers.
>>
>>58966550
That nobody else even mentioned FizzBuzz, while the question was obviously related to it.

>>58966794
They actually said "Well at least you're familiar with it. Most people have no idea when we mention that after they do the problem." (Or similar to that)
>>
>>58966898
Most people have no idea when we mention that after they do the problem.

Meant "Most people have no idea what FizzBuzz is when we mention it after they show us their results."
>>
>>58966883
Did I pass the weeding out process? I usually just foreach through lists of things in my job.
>>
>>58966934
Mate, if you know how to write any functional code without copy/pasting from stackoverflow, you pass the weeding test. FizzBuzz was introduced as an early interview question because a huge number of fresh graduates apply for jobs without knowing any programming. Yes, not programming knowledge at all.
>>
>>58966520
return (33*99) & (20 *100);
>>
>>58966851
I think you could make it more efficient by first checking if it is divisible by 5 and 3 because then for the rest of the else ifs you only have to check one number instead of both.
>>
>>58966971
Imagine having the balls to apply to a job that you have no fucking idea how to do it.

Like imagine applying to a job as a trucker without ever having driven.
>>
>>58967179
Yeah that's a good point.
>>
>>58966851
God damn why is powershell so fucking ugly
>>
>>58966512
But anon, web development is coding.
>>
>>58967226
I hear this a lot from ruby guys
>>
>>58967215
I just got my first internship software engineering internship, so thankfully I know something! Haha.

When I first learned of FizzBuzz and solved it I couldn't see what the big deal was. It seems so trivial.
>>
>>58966971
It's like the simplest test you can possibly ask and it's frustrating seeing people unable to understand the question itself let alone implement the answer.
>>
>>58967536
Not everyone knows what a modulo operation is
>>
>at interview for programming job
>asks me to implement a collision-safe hashmap in c++
>not allowed internet access
>15 minute time limit
>>
>>58967614
If you don't know what it is you shouldn't be applying for a programming job in the first place. That's like applying to be a chef without knowing how to light a stove.
>>
>>58967684
I'm not saying you shouldn't, I'm saying that there are easier tests than FizzBuzz
>>
>>58966520
And that's why you didn't get the job
>>
>>58967614
>not knowing what modulo is
>not knowing how to cast to integer and subtract to get remainder
>not knowing how to floor, multiply, and subtract to get remainder
>not knowing any way to find the fucking remainder on a fucking oversized calculator
>"can i still have the job? i have years of experience in UX design and social justice."
>>
>at job interview
>anon, do you know .NET?
>yes
And that's how I got my job.
>>
File: Castlevania.jpg (71KB, 600x750px) Image search: [Google]
Castlevania.jpg
71KB, 600x750px
>>58967202
Ho, you wouldn't believe.
>>
>>58966851
Because companies want to weed out people who are to retarded to understand that modulus is a thing and lack basic problem solving skills.
>>
>>58967614
That is true. Not everyone knows what a modulus operation is, but a programmer should. If not, the person is not a programmer.
>>
>>58966520
This takes away the primary reason why fizzbuzz kinda confuses some people and why it is appropriate for weeding out total noobs.
This company uses programming test that is literally easier than fizzbuzz.
Congratulations.
>>
>>58964911
An actual company wouldn't give you a computer to do it on, preferring that you show you can code something so basic without having to reference anything.
>>
>>58968797
It's not supposed to be difficult, just a test to see if you know anything about coding.
>>
>>58968953
Regardless, he solved a problem.
>>
>>58968969
But that's what fizzbuzz does. This does nothing.
>>
>>58966520
>>58964911
How the fuck are you finding jobs with such earth interviews

I get 3 hours of shit like this >>58967662
>>
>>58969214
The problem is that FizzBuzz is too well known now.
>>
>>58969297
The problem is that people still fail it.
>>
var a={s:"fizz",n:3},b={s:"buzz",n:5};for(var i=1;i<=100;i++){console.log(i%a.n==0&&i%b.n==0?a.s+b.s:(i%a.n==0?a.s:(i%b.n==0?b.s:i)));}
>>
>>58966520
Thats one of the first project euler problems. Also if you can't do it without a for loop, while loop or recursion (basically do it in O(1) time) I wouldn't hire you.
>>
>>58969499
I don't think any reasonable person would solve this not using a loop when explicitly asked to iterate through 100 to 0.
>>
>>58969499
If you need people who can do fizzbuzz without loops, you don't need fizzbuzz in the first place.
>>
>>58969466
>asked to do a simple basic programming task
>writes a single line with multiple ternary operators and no whitespace
>said unreadable garbage is not even compact
Id' rather hire someone who doesn't know anything about programming than you.
>>
Simple enough lads.
>>
>>58970048
Yet you still failed.
>>
File: 1484136195654.jpg (246KB, 500x500px) Image search: [Google]
1484136195654.jpg
246KB, 500x500px
>>58970080
How so, works.
>>
>>58970087
You've had five minutes. Noticed your error yet or do I need to tell it?
>>
>>58970129
Shoot mate, I'm still learning so I don't really care either way.
>>
>>58970141
Off by one error in iteration. You start from 0, not 1.
>>
>>58970156
So a minor error in the for loop making 0 show up as fizzbuzz? I don't see that as a massive problem. it still shows aptitude in being able to do this does it not? Do employers weigh that sort of thing heavily
>>
>>58970186
Your code does not do what it was supposed to do. That is always a massive problem. The fact that you do not understand this would make your position even worse in an interview.

FizzBuzz tests your ability to use two kinds of basic control structures in programming, loops and conditionals. You failed the first half of it.
>>
>>58967614
Fizzbuzz is still fucking trivial. You just need to answer the following question: Is this number divisible by 15, 5, or 3?

So create a function for it.


public class Modulo {

public static void main(String[] args) {
for(int i = 0; i <= 100; ++i) {
System.out.printf("Number %d:%n", i);
System.out.println(divisibleLoop(i, 3));
System.out.println(divisibleMath(i, 3));
System.out.println(divisibleFloatery(i, 3));
System.out.println(divisibleModulo(i, 3));
}
}

// This is perhaps the most fucking obvious way of doing it. Not very smart, but it works.
// Correctness should be as obvious as the fact that there has to be a better way.
public static boolean divisibleLoop(int number, int divisor) {
while(number > 0) {
number -= divisor;
}

return number == 0;
}

// Wait a minute. If we divide two ints, and it's not perfectly divisible... and then multiply it by the divisor again...
public static boolean divisibleMath(int number, int divisor) {
return number == (number / divisor) * divisor;
}

// This can also be done through float fuckery
public static boolean divisibleFloatery(int number, int divisor) {
float div = (float) divisor;
float result = number / div;

return result == (float) (number / divisor); // this of course can get us fucked due to floats being black evil magic.
}

// Of course if you know about modulo, it might just be a bit easier...
public static boolean divisibleModulo(int number, int divisor) {
return number % divisor == 0;
}
}
>>
>>58970341
How did you manage to make a trivial fizzbuzz that long? Reminds me of
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
>>58970359
I didn't solve fizzbuzz at all.

I just showed 4 different ways of checking if a number was divisible by another number.

The point was that you didn't need to know modulo to solve it.
>>
>>58970403
If you want to go there...
You don't even need to know control structures. Just write a program with 100 hardcoded print statements.
>>
>>58970432
I did once write a program that wrote a program that had fizzbuzz hardcoded.
>>
>>58970403
just divide it as a float and cast it to int Xd
>>
>>58970359
>o-object oriented pr-programming is good guys, I-I swear
>>
>>58969499
literally how would you do it in a constant time? even if you do it in CSS the computer will still spend more time processing more things
>>
>>58970476
Closed form.
There is a math formula you can use to do it.
>>
>>58970476
console.log("1 2 Fizz 4 Buzz Fizz 7 8 Fizz...");
>>
>>58970609
it takes time to load stuff from memory
>>
What is the "optimal" answer to a fizzbuzz (or similar) interview question? Obviously it should be fairly basic with no showoff cowboy coding, but what's the desired answer?

For loop and if-elseif-elseif-else? While loop and switch? Would using slightly more advanced techniques like ternary ifs or short-circuit evaluation be frowned upon?
>>
>>58964911

OMG MATHS
>>
>>58967152
can anyone explain this?
>>
>>58970673
So say for example. Would something like this be a bad solution?
for (var i = 1; i <= 100; i++) {
var str = '';
if (i%3 == 0) str += 'Fizz';
if (i%5 == 0) str += 'Buzz';
console.log(str || i);
}

The short-circuit evaluation shows advanced knowledge of the language, but on the other hand it's far from being language-agnostic. Net positive or negative?
>>
>>58970231

Going to back this anon up. >>58970048 it's not a case of you having an off by one error, you had an error on a basic task, which could lead to massive issues in real life circumstances. Right now, you're a liability.

Keep at it though!
>>
>>58970739
str || i
will evaluate to true.
>>
>>58970739
Net negative, opening brackets belong into an own line for better readability.
>>
>>58970792
only for autists
>>
>>58970792
You're wrong.
All major javascript style guides recommend that style due to the language's shitty semicolon insertion.
>>
>>58970801
Riddle me this, then: why the fuck did he think the closing bracket needs an own line? Why did he even bother indenting code when it's all the same to the compiler? It's a half-assed but failed approach to making the code readable.

>>58970809
> javascript
>>
>>58970835
https://kernel.org/doc/html/latest/process/coding-style.html
>>
>>58970791
You're wrong.

You can run it on your browser console right now if you're not familiar with javascript.
I did say showcases advanced knowledge of language-specific short-circuit evaluation behavior.

>>58970835
Yes, that is the language. Most examples ITT are javascript, in case you hadn't noticed.
>>
>>58970868
Dennis was one of my idols and I mourned his death by quitting my job and drinking heavily for months. Doesn't mean he was right about this specific detail, we all have some flaws.
>>
>>58970903
> javascript is a "language"
kek
>>
>>58970934
Unfortunately it is the most popular programming language on earth by far.
>>
>>58970934
It's a scripting language. HTML is a language, too. A markup language.
>>
>>58970513
>math
fuck off
>>
>>58970739
The answer to your question depends on who's interviewing.

If it was me, then something like this pseudocode would be optimal:

void fizzbuzz(int max) {
void check(int i) {
if(i % 15 == 0) { print("Fizzbuzz!\n"); }
else if(i % 5 == 0) { print("Buzz!\n");}
else if(i % 3 == 0) { print("Fizz!\n");}
else { print(i); print("\n");}
}

loop for i from 1 upto max {
check(i);
}
}

fizzbuzz(100);


This is because:
> You write a slightly more general case, but don't go full enterprise fizzbuzz
> You remembered to start at 1, but I wouldn't hold starting at 0 against you.
> You avoided leaking information, and made check a local function.
> And you actually did make check a local function, thus separating out concerns.
>>
>>58970945
No, Java is TIOBE's #1.
>>
>>58970919
Readability is a bad argument. Whatever you are more used to will be the more readable of the two.
And actually, opening bracket in the next line doesn't even make that much sense. At least not in this way. An if-statement, if true, will evaluate the next statement. So you indent the next statement to show that it will not be always executed. An opening-bracket starts a block of code that will count as one statement in that regard. So you should really do it like
if ((x % 15) == 0)
{
do_multiple();
commands();
}
rest_of_code();
>>
>>58970639
Yes, constant time.
>>
>>58970639
constant time
>>
>>58971024
lol tiobe
https://blog.timbunce.org/2009/05/17/tiobe-index-is-being-gamed/
>>
File: kys.png (67KB, 616x596px) Image search: [Google]
kys.png
67KB, 616x596px
>>58970981
Enjoy being a sub-par code monkey forever I guess.
>>
>>58970513
how do you do that without a sum formel or something similiar (which would pretty much be the equivalent to a for loop)?
>>
>>58971150
*formula
>>
>>58971150
https://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF
>>
>>58971094
Yeah by Pascal 2000 Enterprise edition.

>>58971150
I don't know the English words for "advanced" math, so forgive me for just copypasting wikipedia. At least I won't sound as much like a retard:
> https://en.wikipedia.org/wiki/Geometric_series#Sum
>>
>>58969466
writing obscure code isn't something employers look for.
1) Lay it out well
2) comment the fuck out of it
3) give non-ambiguous variable names
Essentially make it so that someone who doesn't program in you language (or at all) can easily grasp what's going on.
Trying to impress people by taking something simple like fizzbuzz and overcomplicating it just makes you look like you're not serious about producing high quality reusable code.
>>
>>58971150
Well, let me be specific because that Wikipedia article isn't really about the sum formula.

You basically have two sum formulas, one for numbers divisible by 3 (3 + 6 + ... + 99) and one for numbers divisible by 5 (5 + 10 + ... + 100). Those can just be simplified down to 3 times the sum (1 + 2 + ... + 33) and 5 times the sum (1 + 2 + ... + 20), and every respectable fifth-grader knows the formula for these.
>>
>>58964911
>This is how easy it is to code.
That's right. Now, real application development on the other hand...
>>
>>58971039
Yup, I totally agree with you. However, since the brackets are just 1 character, I don't choose to indent them. But, and that's the point, a block of code should start and stop at the same indentation level. Maybe it's autism, but I really hate putting the opening bracket at the end of the line which starts the block.
>>
>>58971302
>Maybe it's autism
/g/ in a nutshell
>>
>>58971226
>(1 + 2 + ... + 33) and 5 times the sum (1 + 2 + ... + 20), and every respectable fifth-grader knows the formula for these.
Which one works for 1..33? Because the Gaussian doesn't.
>>
>>58971318
What?

https://www.wolframalpha.com/input/?i=1+%2B+2+%2B+...+%2B+33
https://www.wolframalpha.com/input/?i=(33+*+34)+%2F+2
>>
>>58971174
>>58971226
Ahh I read the original question wrong, thats why I didn't understand it. I thought it was still about fizz buzz
>>
>>58970737
It's incorrect. It should be 51*33 and 50*11
>>
>>58970739
>javascript
>concatenating strings
wew lad
>>
>>58971881
ok, but how does this work?
>>
>>58971881
Tyop, should be 50*21.

>>58972157
Find the middlemost "success" in the set. Count the successes to the right (as in, higher than the middle). Multiply that count by two, then add one, then multiply that number by the middlemost success.

Essentially, adding the Nth success below the center to the Nth success above the center results in 2*center. Instead of finding the sum, you're finding how many centers you're summing and multiplying by the center.

Don't ever do this in an interview. They're testing your programming skill, not your math skill. You could make a function that finds the center and does the success counting, but that adds a needless layer of complication that'll lose you the job. Bosses want fast, simple, and successful.
>>
>>58964911
If a company's test of programming skills is fizzbuzz, i fear for the future of that company.
>>
>>58972588
Tests like that are fairly common for entry level positions, you know, for kids fresh off school.

Such a simple test is necessary because most of them can't program at all.
>>
File: whatever.png (132KB, 554x439px) Image search: [Google]
whatever.png
132KB, 554x439px
>>58966520
since they ask for the sum you can just do it numerically in constant time
>>
>at job interview
>make fizzbuzz in C
>go to /g/dpt/
>C-f fizzbuzz
>turn it in:
for (i = 0; i < 100; i++) {
switch (i) {
case 1:
printf("1 ");
break;
case 2:
printf("2 ");
break;
case 3:
printf("fizz ");
break;
case 4:
printf("4 ");
break;
case 5:
printf("buzz ");
break;
case 6:
printf("fizz ");
break;
case 7:
printf("7 ");
break;
/* And so on */

>congratulations anon
>I get the job
Now I copypaste fizzbuzzes from /dpt/ to some enterprise's computers for a living.
>>
>>58964911
No, that's how easy it is to fool some incompetent HR person into thinking you can code.
>>
>>58966851
>sysadmin
mein neger
Thread posts: 112
Thread images: 8


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.