Since there are a fair number of programmers on this site, I thought it might be fun to pose problems and swap solutions, and I thought it might be fun to do it on a basis something like the "name that gun game", with the difference that there's more than one right answer, so we'll need to collectively pick the "best" answer to decide who is next up.
So, here are the rules that I think will make this fun and work well:
- Questions can't be too hard. They should be solvable in no more than 20-30 lines of code, and shouldn't take too much time.
- Questions should be specified relatively completely, but it's okay for others to ask questions to clarify the parameters. In real interview questions, you're actually expected to ask questions, but that might take more back-and-forth than would work well here.
- There's a time limit. 48 hours after a question is posed, the best answer will be collectively determined (more on that) and the winner gets to pose the next question. If the winner chooses to pass, anyone can pose the next.
- You can use any language you like to respond, but it's recommended to choose a mainstream option like Java, C, C++, Python, etc. These sorts of problems often have uber-cool solutions in functional languages, but most people don't know how to read them.
- The "best" answer is determined according to the following criteria: asymptotic efficiency, novelty, elegance and clarity. That list is in order. Asymptotic efficiency (i.e. big-O efficiency) is more important than anything. An O(n) solution beats an O(n^2) solution no matter how ugly it is. The others are a little more flexible. Note that with real code, I would put clarity in second place, but for fun novelty is great and elegance (which comprises brevity, cleanliness and beauty) is very pleasant (of course, elegant code is almost always clear).
- If there are multiple solutions, the first one to get two votes by people other than the author is considered to be the best. Or, if 72 hours passes, the first one to get a vote by anyone other than the author wins.