by wewewedxfgdf · 8mo ago · 0 comments
"What number am I thinking of?"
Smart developers - really smart developers are always right. Truly great developers have seen this sort of problem before and know how to attack it - they need no fancy questions or "deeper understanding". They simply hit the whiteboard, do the logic and output the answer.
Don't settle for anything except A players.
Same with your last sentence.
I don't think this is a good interview question, but I do think it is interesting as a thought exercise.
I bet that perhaps 25% of candidates could actually answer the question correctly, even if they didn't know anything about Schelling points. It could also lead to some nice discussions about how to solve an open-ended problem, probability distributions, strategies for maximizing payoffs when making decisions in the face of uncertainty, and so on. The question is so bad, it's actually kind of good.
But assuming you are unwilling to answer any additional questions, the correct solution is to simply brute force every number up from 0 and its negative.
% isIt3
10
0
6
4
8
0
9
5
I found three
----
proc isIt3 {} {
variable 3 [expr {int(rand()*12)}]
switch $3 {
3 { puts "I found three" }
default { puts "$3" ; isIt3 }
} ;# end switch
} ;# end proc
The number you're thinking of is 3. (-: