Live data from Hacker News

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

news.ycombinator.com

171–180 of 363 posts

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

#171
post #59

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…

The Monty Hall problem (or a subtle variant) is also great one to watch people work through. It's a chance to see if people can thing about probability in a sort of asymptotic way. Basically (if they get stuck), ask them how they would choose if there were actually a 100 doors, but the same rules apply. Obviously, everyone switches. What about 99? 98? ... turns out, 3 doors is the smallest number where the strategy i…

Depressing, just asked my coworkers this and can't convince them it isn't an independent event :(.

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

#172

Earlier quoted context omitted.

My wife and I have discussed this, and get a different answer to a few of the solutions we then googled for. I think it is as simple as: http://pastebin.com/gg5DTySG

I'm thinking this: http://pastebin.com/GW1hTXwD Dying to know if I made it through the math FizzBuzz :)

There is a mistake in the deduction in the second sentence. The chance that you picked the fair coin is approximately 49% not 1/1024.

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

#173

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…

That's a nice filter. (Of course, I'm a former mathematician as well.) Here's how I think of it: - the prior odds that you picked the double-headed coin are 1/999. - after seeing ten heads, the posterior odds that you picked the double-headed coin are (2^10)/999 - let's approximate this as 1. (Bayes' theorem usually gets expressed in terms of probabilities, but it's so much simpler in terms of odds.) - so it's roughl…

0.7531 if you don't assume that 2^10 = 999

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

#174
post #35

Earlier quoted context omitted.

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…

There are three ways to define a function in Javascript; the third is exemplified in the example above, although it's not usually done with the same name for the variable and for the function.

The value of naming a function as you assign it to a variable is that, when an exception arises within the function body, your error log output contains the function name, which doesn't always happen when you simply do "var foo = function () {...}". (It's also handy when you're using an editor which doesn't understand Javascript well enough to understand that "var foo = function () {...}" actually creates a function named "foo"; in such cases, explicitly naming the function clues in the editor's parser, which simplifies code navigation.)

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

#175
post #59

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…

The Monty Hall problem (or a subtle variant) is also great one to watch people work through. It's a chance to see if people can thing about probability in a sort of asymptotic way. Basically (if they get stuck), ask them how they would choose if there were actually a 100 doors, but the same rules apply. Obviously, everyone switches. What about 99? 98? ... turns out, 3 doors is the smallest number where the strategy i…

One issue I have with Monty Hall problem as an interview question is that the problem statement is too subtle, with several hidden assumptions. Interviewers often end up posing a different puzzle without realizing just by using a slightly different language to pose it.

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

#176

Earlier quoted context omitted.

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?

Ask yourself a question: can you use the data (the 10 coin tosses) to update the probability of the current coin being two-headed?

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

#177

Earlier quoted context omitted.

find path -iname "*.mp3" -print0 | xargs -0 rm -fv

I'd give half marks for this, because it optimizes (meaninglessly) for processes, at the risk of ending up with "rm: Too many arguments" in a directory tree containing a sufficiently large number of MP3 files.

zero marks for not understanding how xargs works

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

#178
post #17

Earlier quoted context omitted.

I've found 'list 10 two-letter linux commands and their use' They don't actually have to think of 10, but their answer can show what they've actually had to do on a *nix system. Its also lets you prod them with questions like 'how might I get disk usage' or if they mention dd, ask them how they use it, what its good for etc.

I was surprised I could actually think of 10. Using both dc and bc seems like cheating, though ;)

To be honest, a reason I like it is that if they free-think and say 'what about sed, oh of course thats three characters', shows what they know. Also whether shell-built ins count too.

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

#179
post #175
post #59

Earlier quoted context omitted.

The Monty Hall problem (or a subtle variant) is also great one to watch people work through. It's a chance to see if people can thing about probability in a sort of asymptotic way. Basically (if they get stuck), ask them how they would choose if there were actually a 100 doors, but the same rules apply. Obviously, everyone switches. What about 99? 98? ... turns out, 3 doors is the smallest number where the strategy i…

One issue I have with Monty Hall problem as an interview question is that the problem statement is too subtle, with several hidden assumptions. Interviewers often end up posing a different puzzle without realizing just by using a slightly different language to pose it.

That's true, the rules really do have to be laid out in plain language to be a fair question.

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

#180

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?

The history of coin flips has no effect on the future tosses, BUT you can use the history of flips to try to infer which coin you are dealing with.
Post reply on HN