Ask HN: FizzBuzz for mathematicians ...
We have enough mathematicians here to ask this: What would you suggest as an equivalent of FizzBuzz for mathematicians?
Some suggest proving sqrt(2) is irrational, but many technical types who aren't really mathematicians can do that because they've read enough popular math books. Similarly proving that there are infinitely many primes.
So, mathematicians, what would you suggest?
And for the non-mathematicians, what would you like to have explained, that you think every mathematician probably knows?
Added in edit: I thought this was a great discussion with some interesting suggestions, but I see it's been flagged off the front page.
http://hnrankings.info/4244266/
So that's that, another interesting discussion killed. Oh well, never mind.
88 comments
[ 2.9 ms ] story [ 175 ms ] threadSomething less "cool" would be more apt imo (fizzbuzz itself is rather uninteresting).
Another proof (requires more knowledge) is based on the structure of the real numbers. Let a and b be real numbers where a ≠ b. Then, there are infinite numbers between them. It's a pretty obvious statement.
Now, try to find any number between 0.99... and 1. You can't. So, if there isn't any number between 0.99 and 1, they are equal.
Well, fizzbuzz doesn't exactly require a masters degree either. Proving sqrt(2) is irrational requires at least some understanding of how math problems are approached (unless you do it completely from memory, which is also possible with fizzbuzz), so I would say it's the equivalent.
I have a CS degree and took a bunch of math courses and did lots of proofs, but now (several years later) I'd struggle to write any of the suggested proofs.
* Show that two irrationals can add up to a rational.
* Find three whole numbers in arithmetic progression whose product is a prime.
* Find a prime that is one less than a square. Now find another.
Edit: Nevermind - I just figured these out. Makes me feel a bit dumb now. That's what I get for not doing math for a few years. I really liked the last one - got me thinking.
I don't think there's an agreed upon definition of what a "whole number" is. Then again, if you're just looking for how someone reacts to such a question, I suppose it's fine, if a bit silly.
All integers, integers >= 0, integers > 0
• The positive integers
• The non-negative integers
• The integers
I have definitely come across the usage in more modern settings as well, however.
I know that 1 is not considered to be a prime now, but it was considered to be a prime by most mathematicians up through the 19th century, and Lehmer included it in his lists of primes as late as 1956.
For 2, how about -3, -1 and 1.
For 3, 3 is the only example. One less than a square is n ^ 2 - 1 = (n+1)(n-1). For n=2 the answer is 3 (3*1). For n > 2 the result is clearly factorable into two numbers > 1.
2. The first is far more quickly solved by definition of the additive inverse, anyway.
Or 7, or 31, or 127.
It's just about as simple as FizzBuzz, and requires primarily symbolic manipulation. Anyone from any branch of mathematics (including applied math and statistics) should be able to do it in their sleep.
Two players play a game with a single six-sided die. The player that starts can only win by rolling a 1. If he or she doesn't win, the other player gets to roll; he or she can only win by rolling a 6. The game continues until one player wins. What's the probability the first player wins (eventually)?
What information does that give to you as an interviewer?
Player 1 wins based on the following series:
Chance to get a 1 (turn 1): 1/6 Chance to be allowed to roll: Previous chance to be allowed to roll * 5/6 (Chance player 1 didn't roll a 1) * 5/6 (Chance player 2 didn't roll a 6) Chance to get a 1 (turns 2+): Chance to be allowed to roll * Chance to get a 1
So... summation( 1/6 * (25/36)^(n-1) )
I don't know what that comes out to be.
It's simple to figure out with pen and paper but the goal is to just confirm a basic level of competence.
You can have the person then turn it into a general case. What is the sum of 1...N given that the numbers divisible by x1...xk. Even that's pretty simple though.
In any case I'm going to suggest this:
Q. Give two different proofs of the fundamental theorem of algebra.
I really, really, really want to know an example of that.
(Philosophical logicians do not score as examples of this).
This is actually more reasonable than expecting an analyst to produce basic group theory proofs.
This was in Australia in the early 80s, and to this day I think of TSs as sort of obvious. But I did Pure Maths, and I think TSs are more emphasised in applied where you use them for approximations, etc.
Which aspects of your undergraduate real analysis course did you not find obvious (if any)?
But this was 32 years ago, and while I've used calculus in one form or another constantly, I've never had to do anything "interesting" with Taylor Series. Now looking back I'm hard pressed to say what was easy and what wasn't, what was obvious and what wasn't.
It would actually be interesting to go be an undergraduate and see what is obvious now with the years under my belt, and what needs to be thought about hard.
Edit: If this is too easy, prove that g in G, g -> g^2 is a homomorphism iff G is abelian.
Note: I am not a mathematician.
In that same vein, I'd suggest proving that a group G is abelian if and only if (ab)^2 = a^2.b^2, where a, b are in G.
It's not as straightforward as your question in the sense that proving it requires a little idea that you have to come up with.
To be clear, however: I think these are pretty good analogues of FizzBuzz.
(ab)^2 = aabb a^2 b^2 = abab
ab = ba iff G is commutative, so for an Abelian group we can substitute for the middle bit
aabb = a(ab)b = a(ba)b = abab
Which won't hold if G is not commutative.
QED
I recognize that FizzBuzz is supposed to be easy, but it's supposed to recognize programmers with basic competence; I am not a mathematician. (But maybe I underestimate myself or overestimate some of those with advanced degrees in mathematics?)
aabb = a(ab)b = a(ba)b = abab
fail to prove the if?
edit: I did fail to re-state it, but figured it was obvious in the not-really-formal-proof setting. If that's all you meant by "a bit murky" then nevermind.
Not exactly relevant to practice, and utterly trivial, but I suppose nobody comfortable with formal math should any problem solving it on the spot.
Fizzbuzz isn't trying to separate the professional programmers from the pretenders, its' trying to identify people who have no capacity for programming whatsoever. Fizzbuzz only requires basic knowledge of the syntax of any programming language and basic problem solving skills. I think a better equivalent would be something like "integrate x*e^x". Or maybe even some college-level algebra.
However, since both problems are fairly trivial proof-by-contradictions, I would like every computer scientist to be able to solve them as well.
That said, my masters degree is in programming languages, so I may be exposed to a bit more math than the average software developer. I do not consider myself competent enough to be a mathematician, though.
EDIT: OK, that one is more for engineer. How about: find a bijection between R and P(N)?
I would also suggest this: Prove exp(pi*i)+1=0.