Fizzbuzz

Serious question here. Do companies seriously use fizzbuzz to test their internship/candidates? It seems so trivial

Attached: cya9jm5ewwc11.jpg (1200x1200, 254K)

I licked a negro once

How crippling is the aids?

>It seems so trivial
Yes. You'd be surprised how many "qualified" candidates aren't able to complete the task.

it's trivial in python... i wrote this in about 90 seconds:

for i in range(0, 101):
if (i % 3 == 0 and i % 5 == 0):
print "FizzBuzz"
elif (i % 3 == 0):
print "Fizz"
elif (i % 5 == 0):
print "Buzz"
else:
print i

if they ask you to write it in ASM or FORTRAN 77 or COBOL though it might get tricky...

What is fizzbuzz.

fuck niggers
programming is for cucks
i am just a consumer

>it's trivial in python
and still you got it wrong

why cuz it printed for 0 instead of starting at 1?

don't tell him, what an idiot.

Usually they don't use that one, just because it's easy to learn, and lots of people do it as a practice question. But the coding portion of many a tech interview are just as trivial.

Just as important to solving it though, is the ability to correct and take corrections or curve balls without flaking out or getting defensive.

yes, zero is a multiple of neither three nor five

Here's a good recursion problem for you brainlets:

Given an array of ints, is it possible to divide the ints into two groups, so that the sum of the two groups is the same, with these constraints: all the values that are multiple of 5 must be in one group, and all the values that are a multiple of 3 (and not a multiple of 5) must be in the other. (Recursion only, no loops needed.)


split53([1, 1]) → true
split53([1, 1, 1]) → false
split53([2, 4, 2]) → true

meh, fine

for i in range(1, 101):
if (i % 3 == 0 and i % 5 == 0):
print "FizzBuzz"
elif (i % 3 == 0):
print "Fizz"
elif (i % 5 == 0):
print "Buzz"
else:
print i

douches.

We ask candidates to carry out a fizzbuzz equivalent in pseudocode. In excess of 60+% of candidates fail it. We lose even more when we ask them to concatenate a string or add two numbers in a language they assure us they are an expert in.

>yes, zero is a multiple of neither three nor five

are you retarded? zero is literally by definition a multiple of every element of a field, including itself, which is why multiplication by it is non-invertible.

what languages do your candidates say they are experts in? Java? C?

us python guys pity the masochists hailing from the island of Java and the C sea

this had been way more comlicated than it should had been
public class Split {

public boolean split53(int[] input) {
return splitLayer(input, 0, 0, 0);
}

public boolean splitLayer(int[] input, int layer, int leftGroup, int rightGroup) {

if(input.length == layer + 1) {

if(Math.abs(leftGroup - rightGroup) == input[layer]) {
return true;
} else {
return false;
}
}

if(input[layer]%5==0) {

return splitLayer(input, layer + 1, leftGroup + input[layer], rightGroup);

} else if(input[layer]%3==0) {

return splitLayer(input, layer + 1, leftGroup, rightGroup + input[layer]);

} else {

return splitLayer(input, layer + 1, leftGroup, rightGroup + input[layer]) || splitLayer(input, layer + 1, leftGroup + input[layer], rightGroup);
}
}
}

who overpromise the most

is it the loo folk?

Not him, but we've had candidates claim Linux expertise that couldn't tell us what their favorite shell was. Or what a shell was. Or how to find out what files were in a directory.

It was sad. Also, it was when we started blacklisting specific recruiters for wasting our time with worthless candidates

still wrong

I interviewed about 10 candidates at the last place I worked, and we used fizzbuzz as the first of two programming problems.

About half of them struggled with it, and a senior dev candidate actually told me the second problem was impossible.

It isn't something to base your entire interview on, but it's a good filter for basic programming skill.

well that's disgraceful...

but i do think that the world of Java, in particular, does create fairly experienced programmers, who have a niche, but would fail at questions like "now compile your program using javac and run its main class" or "deploy your servlet in a tomcat server and show it to me"...

it's because the java programmer's life is "type around in the IDE, have it do syntax checks, then commit and have jenkins run unit tests, then it gets auto-deployed via puppet" or some shit. java programmers typically never EVER type "javac" onto their command line, and it's a shame that they're so niche that they don't know the basics of their language

that's, i think, maybe why the guy saying "ask candidates to concatenate a string" is getting so many failures. probably every C++ programmer has some boost library to help with string manipulations, and fail because that's all they remember but aren't allowed to import it on the interview exam

then fix it and post the updated code if you're so smart. friggin douche.

Fizzbuzz is just the first question. It shouldn't take more than 5 minutes of the hour-long interview slot.

>and a senior dev candidate actually told me the second problem was impossible
What is the second problem?

Bopping for interested

Any problems with this fizzbuzz solution?
for (int i = 1; i < 100; i++){
if (i%3 == 0) {
cout

why do people freak out about this? even if you have no clue what you are doing all you have to do is remember 10 lines.

Some do, of course. Depends on company and position, but sometimes it can legit instantly filter out like 50% or more of candidates who appear qualified on paper.

print(['fizz'*(i%3==0) + 'buzz'*(i%5==0) or i for i in range(1,101)])

Yes because you are printing from 1 less than 100 not equal to 100, so you print 1 - 99 not from 1 to n but 1 to n - 1
Then you also print using ifs not else ifs, so when you hit a number that is for both 3 and 5 (like 15) you are going to print

Fizz
Buzz
FizzBuzz

it should just be FizzBuzz

you are not hired sorry kiddo

I think you stole this from codingbat

cout

This.
#include

int main(void) {
char s[] = "%i\n\0\360\237\215\276\360\237\220\235\n";
short *p = (short*)s, x = p[4] ^ p[6], n, m;

for(m = n = 1; n

Ugh. This thread again.
for (int i = 0; i < 101; i++) {
if (i % 15 == 0) {//if i is divisible by 5 and 3
Console.WriteLine("FizzBuzz");
} else if ( i % 5 == 0) {
Console.WriteLine("Buzz");
} else if ( i % 3 == 0) {
Console.WriteLine("Fizz");
} else {
Console.WriteLine(i);
}
}

You got me. I got in a hurry and didn't double check my condition. I also failed to copypaste the closing bracket.

re: logic. It's all sound. that third condition catches those ints that are not evenly divisible by 3 or 5.

Thank you, famalam

That is incorrect. 0 is a multiple of every integer but itself.

If a and b are integers, then a is a multiple of b if there is another integer c so that a = b * c.

So by the definition if we assign a the value of 0 and assign b any integer value, c will always be 0. Unless the you end up with (0/0) in which the set is undefined.

Attached: 1511924720830.gif (593x900, 216K)

>it seems so trivial
That's exactly why it is used. If someone cannot understand something as simple as modulo, they have no place working as a software engineer.

Yes, it's used to filter out liars and women

Ha thats clever, I've never seen that one before

i've had tons of easy tests in interviews. reversing a string array in c, reversing a red black tree in java, creating a really basic internet cache. never got fizzbuzz but wouldn't be surprised.

I actually had this in an interview recently. Most of the time I get something a little more unique, like finding all the primes under 100, so I was surprised to see this
come up.

recur [] lacc racc = lacc == racc
recur (a:bs) lacc racc
| a `mod` 5 == 0 = recur bs (a+racc) lacc
| a `mod` 3 == 0 = recur bs racc (a+lacc)
| otherwise = (recur bs (a+racc) lacc) || (recur bs racc (a+lacc))

solution xs = recur xs 0 0


This is O(2^n), but I think I could come up with a dynamic programming version,

>baited on an NP-hard problem in a fizzbuzz thread

Am I the only one who thinks it should be considered cheating to have a condition that actually prints "FizzBuzz"?
I swear the first time I heard about this problem I thought the entire challenge was to handle all the various conditions that could print Fizz and Buzz, including catching the condition where it's both and making it trigger both independent print statements.

When you can just print "FizzBuzz" the whole challenge boils down to nothing but knowing you can check for mod 15. Fucking trivial and pointless.

If you answer with an obviously super pre-planned solution like that you look like you just copy/pasted it.

kek what?
>This guy has clearly seen fizzbuzz before. RED ALERT.

Not specifically just fizzbuzz but pretty much any algorithm that has a "trick" to it

If someone whiteboards a stackoverflow one-liner you know there's a decent chance it's not their first time seeing that specific problem

#include

int main (int argc, char** argv) {
unsigned i;
for (i = 0; i < 1000; i++) {
if (i % 3 == 0) printf("Fizz");
if (i % 5 == 0) printf("Buzz");
printf("\n");
}
}


This is unironically used by a lot of companies tbqh. Good filter for a lot of basics.

So what? Do you understand what the point of fizzbuzz is?

if you are associating the word challenge with fizzbuzz you are doing something wrong

>is it possible to divide the ints into two groups, so that the sum of the two groups is the same

You lost me there. You cannot sum groups. Splitting up an array into multiple subarrays does not alter the total sum of all the values anyway so what's the point of that phrase?

>You cannot sum groups
what are you smoking

Sorry bud, you'd be one of the filtered.

You can sum the values of a group but not multiple groups.
For example:

split53([1, 1]) → true

The array only holds two elements: 1, 1
Neither are multiples of 3 nor 5, thus you cannot put them in either group. The sum would be 2 while the sum of the other groups (div by 3 and div by 5) is 0. Yet the function should somehow return true? The entire exercise makes no sense.

You can do it as a one liner

To test if bootcamp retards know how an if statement and a for loop works?

>all the values that are multiple of 5 must be in one group, and all the values that are a multiple of 3 (and not a multiple of 5) must be in the other
Dude. Drink so coffee or something. 1 is not a multiple of 3 or 5 and therefore can go in any group.

Guile:
(let fizzbuzz ((n 1))
(format #t "~a\n"
(cond
((= 0 (modulo n 15)) "FizzBuzz")
((= 0 (modulo n 3)) "Fizz")
((= 0 (modulo n 5)) "Buzz")
(else n)))
(if (< n 101)
(fizzbuzz (+ n 1))))
(reposted to fix formatting and remove useless variable)

>creating a really basic internet cache
Save the result of accessing certain url and give it until some time elapses/cache becomes too big?

(format #t "~a\n" (map (lambda (n)
(cond ((= 0 (modulo n 15)) "FizzBuzz")
((= 0 (modulo n 3)) "Fizz")
((= 0 (modulo n 5)) "Buzz")
(else n)))
(cdr (iota 101))))

>Be interviewing candidate last week
>Use laptop loaded with some sample real-world C# code from one of our apps and ask him to fill out a particular method stub to call some other code to solve some bullshit made-up problem.
>"Oh it's been years since I've coded in dot net"
>(It was one of the top things on your resume, fucker)
"Well we can help you out with syntax hints if needed, we're interested in your thought process"
>deer_in_headlights.exe encounters a timeout exception
"Okay, well let's break the problem down even further for you, instead of relying on this ReportStatGeometryConverter class, how would you code finding the average of a collection of numbers?"
>"Oh I don't exactly remember the algorithm for calculating an average"
>[internal screaming grows monotonically]
"Okay.... well how about finding the sum of an array of numbers? how would you do that in javascript, the language you say you have the most expertise in?"
>I spend next several minutes dropping hints on things like "for" and "+"
>"Oh well I normally have a personal cheat sheet that helps me remember these words and symbols, but I don't have it with me"
>At this point I'm morbidly curious how low I can go before a glimmer of intelligence appears. But I ultimately have to spell out this toddler-tier javascript for-loop on the whiteboard and explain what each fucking thing does, doing an illustrated example that adds 3 array elements.
>The hapless loopless fucker still claims to be an expert

My boss apologized afterwards and said he'll try to be better about weeding people out with his phone interviews before bringing them on-site.

Attached: .png (1024x576, 1.18M)

WHERE DOES IT SAY THAT
IT DOESN'T SAY THAT AT ALL
YOUR EXERCISE IS BULLSHIT
LET ME OUT OF HERE

are you retarded?

europoor here. do explain me how do you play that shit as children, since from wikipedia i understand it's a children game

it doesn't make any sense. here we draw squares with numbers and jump from one to other

c'mon tell us

i % 15 is faster to evaluate than 3 && 5

No you are, you didnt print the number if its not fizz or buzz.

Most companies aren't looking for efficient code. They want functional code. That's why they use fizzbuzz as an interview question.

Why do you need to add add int before I at the start of that for loop? Genuinely curious

Unless you're using C89 or some shit most programming languages let you declare i in the loop.

>mfw 3*5*0 != 0

They don't care but you should be able to do it. Trivially. It's a nice filter because it is so trivial

For (i = 1...

Works just fine in js. No need to declare

for (i = 1; i < 101; i++) {
if (i % 15 == 0) console.log('Fizzbuzz');
else if (i % 5 == 0) console.log('Buzz');
else if (i % 3 == 0) console.log('Fizz');

console.log(i)

}

Huh... So it does...

Where the fuck are you from. Your word ordering and constructions do not make any sense in any European language.

Yes, i've seen it given out as a paper exercise at group interviews before. Thought it was just a meme until then.

>write it as i = 0
>hit enter before I realize my grievous mistake
>Ohno.gif
>initiating black_hole.exe
>my console is the first to be consumed
>followed by my entire git repository
>eventually, it consumes all of the loli hentai on my hdd
>16tb worth
>before the beast can expand, I switch on my RAID array containing all my condescending anime girls reaction pictures
>and my collection of screenshots of Junkrats hipbones
>the raw amount of data is too much for the beast
>it will take > 1.9b years to consume it all
>anime has saved humanity, once again

That's bloated af senpai.

print " ".join([(i%3

This. I find the fizzbuzz task the most effective tool to highlight the foreign, bootcamp or subpar programmers.