Live data from Hacker News

Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

news.ycombinator.com

161–170 of 363 posts

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#161
post #88
post #55

I build web sites. I would ask that the person complete a series of tasks that involved using Javascript to do a bit a typical DOM manipulations and CSS changes, especially using transitions and whatnot... ...without jQuery.

Just curious, why do you not allow the interviewee to use jQuery? Do you expect the candidate to know JavaScript's DOM-level APIs without having to look them up?

Native API are probably easier to learn, just more cumbersome to use :)

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#162
post #105

For a data scientist I ask "what's a p-value?" Both Junior and senior candidates often get this wrong. The only difference is that senior people bristle at such a simple question before also getting it wrong.

Ok, now I'm confused, because I was under the impression that this is the first thing I ever learned in statistics - that a p value is how likely it is that a value created by chance would have been as extreme as the one the experiment gave. Is this wrong?

It's not wrong, but it did open up some great questions as to what it means to have values created by chance and how that relates to "this experiment".

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#163

Earlier quoted context omitted.

Good question, and one that sometimes comes up when I ask it in interviews. You are tossing the same coin 10 times.

0.5005?

That's what I got.

There's a .999 chance you have a fair coin and a .001 chance you have the rigged coin.

(0.999 * 0.5) + (0.001 * 1) = 0.5005.

Seems too simple, but a coin is a coin, right?

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#164
post #157

Earlier quoted context omitted.

You have the right idea. You're assuming an underlying model for the data. You have a test statistic( that estimates a model parameter) and you have a hypothesis regarding a parameter. The p-value is the probability that you get a test statistic more extreme than the one observed assuming that your hypothesis is true. Ex. You have a sample of 1000 men's heights. You compute the sample average height as 5'9 and a samp…

Yeah, that's what I was taught. So what are people answering instead?

People can be easily lead to misinterpret p-values even if they can define them. Most often people assume that p values indicate something about the correctness of a model or an inference. This is the classic p(d|h) v p(h|d) debate.

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#165
post #121

Earlier quoted context omitted.

Do you mind posting a simple walkthrough for the answer

Sure. The slick answer is The chance of picking the biased coin is 1/1000. The chance of seeing 10 heads from a fair coin is (1/2)^10 = 1/1024. These are nearly equal, so given that you've seen 10 heads, there is a 50/50 chance of having a biased coin. So the probability the next flip shows a head is P(H) = P(biased) * P(H|biased) + P(fair) * P(H|fair) = 0.75 The long answer - Yo want to figure out P(biased | 10H). U…

Isn't the gotcha of this test the fact that the history of previous coin flips has no effect on the next flip, given a fair coin?

The OP is only asking what the outcome of the NEXT flip is, not the probability of flipping 11 heads in a row. Or did I read this wrong?

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#166

Earlier quoted context omitted.

Good question, and one that sometimes comes up when I ask it in interviews. You are tossing the same coin 10 times.

This is a fun question. Can I look at the coin's two sides? If not...I assume you now have to start applying statistical tests (given that a fair coin will only do this once out of 1024 times, what are the chances I've got one of those 999 coins vs the 1/1000 chance that I picked the double headed coin?) or is there some simplifying assumption I'm missing. Anyway--assume I think all that aloud in an interview. What d…

>Can I look at the coin's two sides?

I would give points for just asking that question, because many people bound by conventional thinking wouldn't dare to ask it, accepting default assumption that you can't. I'm not saying this says anything about your ability to solve the problem, but asking the question is a good sign of a supple mind.

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#167
post #121

I was a mathematician, and now work in finance (systematic trading). I've found a reasonable negative filter is A jar has 1000 coins, of which 999 are fair and 1 is double headed. Pick a coin at random, and toss it 10 times. Given that you see 10 heads, what is the probability that the next toss of that coin is also a head? That tests their ability to turn a problem into mathematics, and some very basic conditional p…

Do you mind posting a simple walkthrough for the answer

When we pick the coin, we have 1 in 1000 chance of getting the double heads coin, and 999 in 1000 chance of getting a fair coin. Lets call this P(fair) = 0.001, and P(fake) = 0.999.

When we have the double heads coin, the probability of getting 10 heads is 1: P(10 heads|fake) = 1. When we have a normal coin, the probability of getting 10 heads is P(10 heads|fair) = 0.5^10.

The quantity we want to compute is

    P(heads|10 heads) = P(fair|10 heads)*0.5 + P(fake|10 heads)*1 
                      = P(fair|10 heads)*0.5 + (1-P(fair|10 heads)) 
                      = 1 - P(fair|10 heads)*0.5.
To compute P(fair|10 heads) we use Bayes' rule:

    P(fair|10 heads) = P(10 heads|fair) * P(fair)/P(10 heads)
Here

    P(10 heads) = P(10 heads|fake)*P(fake) + P(10 heads|fair)*P(fair) 
                = 1*0.001 + 0.5^10*0.999.
We fill in the formula we got by Bayes' rule:

    P(fair|10 heads) = 0.5^10 * 0.999 / (1*0.001 + 0.5^10*0.999)
Then we fill in the original formula:

    P(heads|10 heads) = 1 - 0.5^10 * 0.999 / (1*0.001 + 0.5^10*0.999) * 0.5 
                      = 0.75308947108

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#168

This thread makes me feel like a worthless POS but at the same times motivates me to finish learning so many pending topics properly. Nothing's better than an actual test.

A worthless POS would lack to motivation to finish learning...

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#169

Earlier quoted context omitted.

Sure. The slick answer is The chance of picking the biased coin is 1/1000. The chance of seeing 10 heads from a fair coin is (1/2)^10 = 1/1024. These are nearly equal, so given that you've seen 10 heads, there is a 50/50 chance of having a biased coin. So the probability the next flip shows a head is P(H) = P(biased) * P(H|biased) + P(fair) * P(H|fair) = 0.75 The long answer - Yo want to figure out P(biased | 10H). U…

Isn't the gotcha of this test the fact that the history of previous coin flips has no effect on the next flip , given a fair coin? The OP is only asking what the outcome of the NEXT flip is, not the probability of flipping 11 heads in a row. Or did I read this wrong?

You didn't read it wrong, but you probably did fail the test ;-) There is no gotcha in the question, it's just a math problem that you either do or do not know how to solve. This isn't really about intelligence as much as it is about whether you have taken a course on probability. If you flipped 10 heads in a row the probability of the coin you have being the double heads coin increases dramatically, so you have to take that into account for the next flip. For intuitive understanding it often helps to go to extremes. Suppose you do 1 billion flips and all come up heads. What is the probability that the next flip comes up heads? Because we had 1 billion heads it is virtually certain that we are dealing with the double heads coin, so the probability that the next flip will come up heads is close to 1.

Re: Ask HN: What's your speciality, and what's your "FizzBuzz" equivalent?

#170
post #35
post #11

Working for a web company. Our favourite JS question is, "What happens if you do this?" var func = function func () { // blah };

It looks to me like what happens is exactly what you'd expect, i.e., you end up with a function defined under the name "func", just as you would with any other function name. Is there something I'm missing?

There are two ways to define a function:

    var func = function(){};
    function func(){};
The example above is doing both at the same time... don't know if it's a mistake on their part or not.

However they're probably wondering if the user knows about scope and other such things. Inside the brackets we have a new scope but it has access to top level scope as well. They want to know that you know that stuff.

Try any of the two lines above in a js console (in browser) then type:

    window.func
    this.func
    func
The result should be the same.
Post reply on HN