At interview for java programming job

>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 user, you got the job

This is how easy it is to code.

Other urls found in this thread:

github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
kernel.org/doc/html/latest/process/coding-style.html
blog.timbunce.org/2009/05/17/tiobe-index-is-being-gamed/
en.wikipedia.org/wiki/1_+_2_+_3_+_4_+_⋯
en.wikipedia.org/wiki/Geometric_series#Sum
twitter.com/SFWRedditImages

>things that didn't happen

do you think this is a funny thread, op?

I slightly chuckled

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?"

>I was the only one to ask
What did he mean by this?

You sound like a retard pointing out the obvious

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

FizzBuzz is a trivial question that helps interviewers weed out non-programmers.

That nobody else even mentioned FizzBuzz, while the question was obviously related to it.

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)

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."

Did I pass the weeding out process? I usually just foreach through lists of things in my job.

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.

return (33*99) & (20 *100);

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.

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.

Yeah that's a good point.

God damn why is powershell so fucking ugly

But user, web development is coding.

I hear this a lot from ruby guys

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.

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.

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

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.

I'm not saying you shouldn't, I'm saying that there are easier tests than FizzBuzz

And that's why you didn't get the job

>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
>user, do you know .NET?
>yes
And that's how I got my job.

Ho, you wouldn't believe.

Because companies want to weed out people who are to retarded to understand that modulus is a thing and lack basic problem solving skills.

That is true. Not everyone knows what a modulus operation is, but a programmer should. If not, the person is not a programmer.

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.

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.

It's not supposed to be difficult, just a test to see if you know anything about coding.

Regardless, he solved a problem.

But that's what fizzbuzz does. This does nothing.

How the fuck are you finding jobs with such earth interviews

I get 3 hours of shit like this

The problem is that FizzBuzz is too well known now.

The problem is that people still fail it.

var a={s:"fizz",n:3},b={s:"buzz",n:5};for(var i=1;i

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.

I don't think any reasonable person would solve this not using a loop when explicitly asked to iterate through 100 to 0.

If you need people who can do fizzbuzz without loops, you don't need fizzbuzz in the first place.

>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.

Yet you still failed.

How so, works.

You've had five minutes. Noticed your error yet or do I need to tell it?

Shoot mate, I'm still learning so I don't really care either way.

Off by one error in iteration. You start from 0, not 1.

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

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.

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 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;
}
}

How did you manage to make a trivial fizzbuzz that long? Reminds me of
github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

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.

If you want to go there...
You don't even need to know control structures. Just write a program with 100 hardcoded print statements.

I did once write a program that wrote a program that had fizzbuzz hardcoded.

just divide it as a float and cast it to int Xd

>o-object oriented pr-programming is good guys, I-I swear

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

Closed form.
There is a math formula you can use to do it.

console.log("1 2 Fizz 4 Buzz Fizz 7 8 Fizz...");

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?

OMG MATHS

can anyone explain this?

So say for example. Would something like this be a bad solution?
for (var i = 1; i

Going to back this user up. 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!

str || i will evaluate to true.

Net negative, opening brackets belong into an own line for better readability.

only for autists

You're wrong.
All major javascript style guides recommend that style due to the language's shitty semicolon insertion.

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.

> javascript

kernel.org/doc/html/latest/process/coding-style.html

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.

Yes, that is the language. Most examples ITT are javascript, in case you hadn't noticed.

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.

> javascript is a "language"
kek

Unfortunately it is the most popular programming language on earth by far.

It's a scripting language. HTML is a language, too. A markup language.

>math
fuck off

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.

No, Java is TIOBE's #1.

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();

Yes, constant time.

constant time

lol tiobe
blog.timbunce.org/2009/05/17/tiobe-index-is-being-gamed/

Enjoy being a sub-par code monkey forever I guess.

how do you do that without a sum formel or something similiar (which would pretty much be the equivalent to a for loop)?

*formula

en.wikipedia.org/wiki/1_+_2_+_3_+_4_+_⋯

Yeah by Pascal 2000 Enterprise edition.

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:
> en.wikipedia.org/wiki/Geometric_series#Sum

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.

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.

>This is how easy it is to code.
That's right. Now, real application development on the other hand...

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.

>Maybe it's autism
Sup Forums in a nutshell

>(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.