264 points · by jgrahamc · 2y ago · 243 comments
However, if the interviewee assumes that Ballmer is being adversarial, then you can pick a different value as your initial guess, which causes the probabilities to shift. Even the OP assumes that the interviewee will start guessing with 50, but, because of the way binary search works, you can select an initial guess that is offset from 50 (with a randomized offset each time) to defeat trivial adversarial attacks that attempt to game the heuristic, while still mostly reaping the benefits of binary search.
I'd be interested to see someone do the analysis of what the optimal random-offset-selection algorithm would be to counter trivial adversarial choices.
"I was interviewing a candidate who said he had experience programming on an IBM/370. So I asked him if you perform a character edit format instruction in EBCDIC mode with the leading zero specifier and the numeric value is too great to fit into the allocated field, after the instruction completes, what is the state of the program status word overflow field?" Then trounced the guy for not knowing. The thing is the guy asking the question happened to have worked on that instruction when he worked at Amdahl.
One thing to know is the IBM 360 and descendant family had a commercial instruction set option that, in a single instruction, could take a format value and generate a string output that followed some format specification, kind of like sprintf but with even more options.
"Is the computer operating on American electricity, or European?"
I think like 70% of interviews I ever had were like they were there to prove how smart they are and how stupid I am. I suppose most likely to make me feel stupid and accept lowball offer.
> Well, he guessed 69, sir, so I assumed he was doing some serious game theoretic calculations
Given that 7 guesses covers 128 numbers, you can offset by +/- 14 without actually affecting the "worst case" of the algorithm (i.e. provided you have at most 64 either side of your guess). As you say, randomly selecting this offset would neuter most adversarial examples (purposefully chosen to fall into the gaps of binary search) and would possibly completely remove the benefits from adversarial choice (though a tailored distribution on offset might be required there).
I'd be interested in such an analysis too.
I might be confused, but don't 7 guesses actually cover 255 numbers? I think you have to count all nodes in the search tree, not only the leafs, because you can get the correct number before reaching a leaf node.
Or more generally k guesses cover 2^(k+1)-1 numbers, e.g. with one guess you get the answers correct/high/low, which can cover 3 numbers)
Maybe there is a mistake in my thinking, because this would mean you can cover 127 numbers with 6 guesses so you could not lose the original game.
Edit: My mistake is that you still have to explicitly guess even if you know the precise answer already, so you cannot cover 3 numbers with 1 guess. This means 7 guesses cover 127 numbers.
You can also view it as a recurrence:
f(1) = 1
f(n) = 2*f(n - 1) + 1 = 2^n - 1
But your binary search tree example is more intuitive.The post never answers the question "so what is the real expectation value", which is a more difficult question. But I think if the interviewee chooses a number randomly from 40-60 as the first guess and does a binary search from there, Ballmer can't really improve on choosing his initial number randomly.
I agree that if you choose your first guess somewhat randomly in the 40-60 range (maybe not a uniform distribution though) Balmer would be forced to choose randomly and you would be back at a positive $0.20 EV. For example, you could flip 6 coins and add the number of heads, then flip another coin to decide whether you add or subtract the number of heads from 50 for your starting guess. But I think you would need to randomize your later guesses a bit also.
I now think that not constraining the players remaining choices to follow binary search pattern would completely change the resulting equilibrium and improve the results for the player. But that would be more computationally demanding to calculate because there's a strategy choice for every range of choices. And also I've avoided work for 2 hours by working on this so that's not great haha. I _am_ curious what not constraining the player to binary search would do though...
It seems like a lot of possibilities and I think you can get away with a minimum gap size of one, but let's assume you do 5 3-gaps at 1, 25, 50, 75, and 100 and 2-gaps everywhere else. So start with 51, then 26 and 76. Then go up or down 12, then 6, then 3. If you have a gap of two you flip a coin, if a gap of three you pick the middle one.
Or if you have them write down the number and you think it has double-digits you could put your 4-gaps below 20. Start with 53 and go up or down 24, 12, 6, and 3 (unless it is below 20, then it is multiples of four.) 59 would pay you a dollar.
Your starting guess could be anywhere from 37 to 64 without paying out more than a dollar, but if you start with an extreme, then low odd numbers and high even numbers will have a negative payout. However, I think you can still randomize sufficiently starting with 38 and 63, e.g. 63-31-15-7-3-1.
https://gukov.dev/puzzles/math/2024/09/05/steve-ballmer-was-...
If you know your opponent picks a number uniformly from all numbers that lead to a maximum of guesses, the optimum strategy is a binary search between those numbers, making sure to pick one of those numbers at each turn.
The problem stays completely symmetric under this condition, so there would be two (maybe four due to edge conditions) optimal first guesses summing to 101.
In general, I think the trick still is a binary search where each guess splits the range of options in halves of equal expected/min/max cost (depending on whether you want to optimize for expected/min/max cost).
Of course you can set up the game such that Ballmer has to commit on a number at the start of the game (by sealing it in an envelope or whatever), but that wasn’t specified.
The scenario is framed as a zero sum game: one of us wins. The question is, "should you play?"
In order to answer, you need to be able to determine whether or not there is an optimal strategy that is generally successful.That should include both the assumption that Ballmer has chosen a number adversarial weighed against the random choice.
Honestly, I don't want to work in an environment like that, it was a large US bank and where their biggest problems are not product innovation or focusing on customer but production failures! An area I have rescued several large companies in, apart from payments expertise and made sure I communicated this. But sometimes you get lucky and don't have to find out the hard way that this place is not pleasant.
This is a red flag. To me this signals that a company not only has a toxic culture, but embraces it. Such places attract personalities who love conflict and once there are enough people, they set the culture.
What doesn't get said often is that conflict is a failure of leadership. Often all it takes to resolve conflict is for one very senior leader to snap their fingers and say, "Guys, I want you two to make this happen". But what happens is that leadership is either far too disconnected from the ground to align their teams, or they constitutionally advocate conflict within their teams in the name of competitiveness. Either way, such places can be hell to work in.
I think a good comparison would be your romantic partner "testing" you by asking their friend to try to sleep with you and see if you try to go through with it. This is toxic, manipulative, sociopath level behavior.
Maybe I'm just interpreting your comment wrong :)
The candidates who were otherwise the most competent tended to be the most comfortable with the I don’t know answer. Getting defensive about it I always considered to be a red flag.
But for the luvagod, please state that up front. It wouldn't have been nearly so fun, or informational for the interviewer, if I'd felt like I was failing a quiz.
But this up-front approach of setting expectations seems like a better way to go.
Edit: By honesty in interviews, I mean to a point. There’s some things you absolutely should lie about in interviews (if you’re confident you can get away with it). For instance “what’s your current salary” is a great question to lie about, that they really have no business asking anyway.
This framing has helped me ever since. It helped me emotionally to recognize that finding the limits of one’s knowledge is not a bad thing, it helped me get the job, it helped me interview people, it helped me hire people who knew more than me.
Judging people and getting an accurate read on people is hard. Often people are overconfident in their ability to do it.
- I don't know - I don't have enough information based on the question - I would do it this way generally but this question requires employer specific information.
Not someone that just barreled forward and came up with a defacto answer as the solution. They had to give some sort of admission that they could not really solve the problem as is.
One time I had a candidate who didn’t not know about a single massively obscure thing I’d asked him. He was a DBA for a Chinese ISP that had more subscribers than we had total population in the markets we were operating in. That guy was probably the best hire I ever made. He was always in an incredibly genuine good mood, he was always happy to help everybody, and he’d help people learn how to solve problems rather than just doing the solving for them. Everybody on the team got smarter and more competent working with him, and he was so good at his job that he never even got behind on his own work due to helping other people all the time. I hope he’s still doing well now, before I left that company I managed to make sure he was being paid bucketloads of money (which wasn’t something he ever seemed to be seeking out independently, he was always just happy to come to work and do his job).
I'm honestly never afraid to say those words, if someone doesn't want to hire me because I said it, I dodged a bullet. I'll go where the devs and leads are sensible people.
When they nitpick or push for irrelevant details just to find a reason to say 'no,' it's a massive red flag. It shows they're not really interested in innovation or solving the real problems, like the endless production failures we've already helped other companies overcome. Honestly, in situations like that, the best thing you can do is apologise for wasting their time and walk away. But I get it when they have the job in your area, it's tempting to tolerate the nonsense. Still, it’s a good reminder that sometimes, dodging that bullet is actually a blessing in disguise, even though you are unemployed and running out of money, as I was at the time.
There: the same situation, pre-enacted by Steve Martin in Pink Panther: https://www.youtube.com/watch?v=mBwn7ycR7_Y. Probing one's ancestry until the answer is 'farmers'.
Absolutely yes. I like games. The purpose of games is to have fun. This seems like a fun game for like the first $20, a sum I can afford to play a fun game for 10 minutes.
Then at the end, I get to say "I once lost $20 to Steve Balmer playing binary search", which is a fun sentence I can dine out on, and is worth more than $20 to me.
I feel like perhaps this is why MS under Balmer lost relevance. Too busy looking at the technical and not the human.
If you answered like this in an interview I would definitely not give you the job. I did actually interview someone once who was like this - "How would you do this?" "Well you shouldn't do it. I think you should do this other thing.". He did not get the job.
It's like interviewers don't understand the power dynamics going on during an interview: for the interviewer, this is just their job. Nothing will change for them whether they pass the candidate or not. This could be their 100th interview. On the other hand the interviewee is not paid to be there, they could be doing something else and they are stressed as who knows what kind of egocentric asshole might be interviewing them for a job they want.
If I get a candidate who can make a fun and clear headed remark in such a tense situation, I would read that as them being comfortable with problems and with stress. I would move forward and ask further questions to see their thought process but rejecting someone out of a single question is ludicrous.
For example, recently a colleague had a problem with a rendering tool for Figma, of which we don't have the source code. The tool would take too long exporting a specific design. The team mate tried changing things randomly for days to no avail. Each try would take hours and sometimes crashed the browser.
The solution I gave him was to remove half of the elements and check how that affects the exporting time. Then keep repeating for the groups that still failed. In a matter of hours he found the element that caused a seemingly infinite loop.
Sort of an opposite impostor syndrome?
For the second part of "I'm superior and know-it-all", I'd say it's good ol' jerk-ery?
The temptation that when you are smart you should become the guardian of the world, a world based on your learnings, your ultimate truths, truths you find easier and more quickly found than by the lay-person. Or so the temptation goes. It allows you to license your morality; the ends justify the means. What you are doing evilly now will be paid off twice-fold by the good it will lead to later. Right?
There's the Fundamental Attribution Error and Dunning-Kruger effects too. And on behavior... Illusory Superiority combines with Moral Licensing (allowing yourself to be equally good and evil because you "match the two") and the dis-inhibition effect which people with greater success take more risks (including affecting other people negatively).
I think these effects all sort of combine. It's not necessary intelligence but power, at least as perceived by the individual that seems to be a bit of an issue (e.g. the individual who thinks they are smarter at doing X innately feels more powerful and then has less inhibition about expressing their superiority and trying to dominate over others).
We've all seen the person who ought to have moved on who hangs on to their former glory fail to understand they are not in prime condition and who tries to exert power they nolonger hold too.. to me that is the real opposite of imposter syndrome. it's when peoples perception of themself and social dynamics don't move with the times.
Narcissistic Personality Disorder
Sociopathy
Dunning–Kruger effect
From the wikipedia article you link:
> Among laypeople, the Dunning–Kruger effect is often misunderstood as the claim that people with low intelligence are more confident in their knowledge and skills than people with high intelligence.
The dunning krugger effect is widely regarded as the polar opposite of it:
- "If the Dunning-Kruger effect is being overconfident in one's knowledge or performance, its polar opposite is imposter syndrome or the feeling that one is undeserving of success. People who have imposter syndrome are plagued by self-doubts and constantly feel like frauds who will be unmasked any second." [1]
- "This is the opposite to the Dunning-Kruger effect. The Imposter Syndrome is a cognitive bias where someone is unable to acknowledge their own competence. Even when they may have multiple successes they struggle to attribute their success to internal factors." [2]
- "The opposite of the Peter Principle and Dunning-Kruger effect is the imposter syndrome. This is when smart, capable people underestimate their (...)" [3]
[1] https://www.psychologytoday.com/intl/basics/dunning-kruger-e....
[2] https://www.leedsforlearning.co.uk/Pages/Download/28541a2c-3....
[3] https://www.forbes.com/sites/jackkelly/2022/07/12/what-the-p...
Turns out he was using this one question to reject people his whole career.
It was a humbling experience to all of us, to recheck everything before we asked questions. Most of the candidates you interview are perfect hires. Some times its you who is wrong.
That also seems like a bad interview strategy. Make a mistake and you're out? Did you have so many perfect people to hire that you could just sort out almost everybody?
They have to pretend to like they are working on things so special and hard that only the absolutely best would cut it.
“Secondly, when significant money is involved, I make sure to verify any inputs. I’m considering the situation, not you personally, untrusted. How can I verify it, or do you want me to proceed assuming that’s verified?”
Those are great questions, but it’s also about how you ask it. SWE is not pure engineering. Communications is vitally important.
The interviewing game of asking clarification questions is silly and should stop. In the system design portion I can understand it, but not when asked a direct technical question.
It's perfectly fine to ask followup questions with added constraints or just directly say that the specification is fuzzy and needs to be clarified first, but having that dance around the basic specs in nonsense (as if you wouldn't know if you're dealing with a 10PB array or 1kb at work).
This is anything but a direct technical question though.
> It's perfectly fine to ask followup questions with added constraints, but having the guessing game to figure out those constraints is nonsense.
You say that. I say people being able to ask the right question is one of the most important skills to be a productive developer. So of course as an interviewer I want to know if they can do it.
I don't know how it works where you are, but we don't have a big book of perfectly defined specifications for our work. I guess if we could get one of those that would improve our productivity. But until we obtain one we will keep testing candidates on their ability to ask questions.
And frankly this is a needed skill. Candidates who automatically think about adversarial scenarios tend to write more defensive code, not to mention fewer vulnerabilities.
Which is not surprising, because she's a professional journalist! It's amazing that Ballmer (like so many technical interviewers) is so pleased with this question that he couldn't help bringing it up, even though it's not really that relevant to Chang's question.
There's obviously a huge gap between the 5-number game and the 100-number game; it's possible that the best mixed strategies settle down as the number of choices gets larger, or (for all I know) it's possible that the best mixed strategies get crazier and crazier. I'd love a ping if anyone does any real exploration of the 6-, 7-, etc.-number games.
For anything else, the candidate has a strategy of "guessing a trick number", and Ballmer has a strategy of "not choosing a trick number".
The candidate can't force Ballmer to try to be tricky.
Reminds me of the viral video, goes something like "I'll pay you $20 if I can pour 2 cups of water on your head" and then only pour 1 cup and walk away.
As the old saying can go, "It depends on what the meaning of 'can' can be."
What often happens maths/physics majors excel at programming the small, but cannot architect things in the large. As a friend once put it about one such person: "He can only do it as long as he can fit the whole problem in his head at once."
It's great to have mathematicians and physicists in the team. But you for sure want a sufficient number of trained and experienced software engineers as well.
The math in this problem is rather simple, actually.
Perfect information = Chess Imperfect information = Poker
This fits into the latter category - if player 2 knew everything that player 1 knows, they would behave differently.
> Ben: He's gregarious. Anyone who's ever met Steve or seen a video of Steve, you are well aware that this man has a presence. But the thing that people don't know about him is he is so unbelievably analytical. Steve is the guy that outscored Bill Gates on the Putnam exam.
PS: Recruiters generally come from the same cloth as car sales and sports, so they're not usually going to be the sharpest pencils in the drawer.
Aren't you committing a similar mistake here, saying that recruiters can only recruit? At my former job one of the recruiters was an engineer for 20 years. He said he just wanted to do something different after all these years.
Almost everything is technical if you focus on it long enough, because almost everything is complicated.
This is because almost everything interacts with the real world, which is hellishly complicated and detailed.
> as either exclusively technical or nontechnical
This applies outside of tech or generally in any role e.g. if you're a backend engineer they assume you don't know frontend or if you're a marketing specialist you're not good at sales.
I never get it either. We're people not machines but most people have this assumption like we're a game character - you get a job / trait and that's it.
GT?
Yes, business manager.
> Interesting how he became technical as the company grew.
That's not clear from this. This shows he knew some concepts as part of managing different teams in the company.
from itertools import count
from statistics import mean
INITIAL_PAYMENT = 5 # dollars paid if first guess is correct, minus 1 for each incorrect guess
RANGE = range(1, 101) # the range of numbers to guess from
def simulate_guess(target):
low = min(RANGE)
high = max(RANGE)
for bad_guesses in count():
match guess := (low + high) // 2:
case _ if guess < target:
low = guess + 1
case _ if guess > target:
high = guess - 1
case target:
return INITIAL_PAYMENT - bad_guesses
average_payout = mean(map(simulate_guess, RANGE))
print(f"\nExpected value per game: ${average_payout:0.2f}")Absolutely. Best case I can tell everyone I beat Steve Ballmer in a bet. Worst case I tell him to take his winning dollars out my first paycheck...
Eg. Can I stop at any time? If yes, I will stop before I go into the negative. If I cannot stop but must continue the game until I guessed the right number, I will most likely lose money. Then go into a simple computation of XY terms where X is the probability and Y is the payout or loss for maybe a dozen terms.
Ballmer states the question as "I'm thinking of a number between 1 and 100." He does not state that the number is an integer. If he's thinking of anything other than an integer, you're unlikely to be successful in finding it via binary search.
What if you combine binary search and game theory?(knowing that he’s trying to beat me and that binary search is my best strategy I have information reducing the randomness of the selection. I know Ballmer is going to choose worst case numbers like 58)
begin with binary search to narrow down the range, then within the range guess the binary search worst case answers. It’s still not guaranteed to win, but might be fun for the chance of taking his money.
Although leading by telling him that the worst case for the optimal algorithm of binary search on n=100 also gets you the job at Microsoft which is worth more than the two bucks you might earn playing the game.
Nice write-up anyway, and yes, Ballmer is wrong.
> Ballmer states that the answer is "No" for two reasons: firstly, because he can pick numbers that'll be the most difficult for you...
The article goes on to show that there are numbers where a binary search always has the guesser paying $1
But he also knows that you know that he could pick numbers that will be the most difficult... So could then pick one of the numbers that actually are guessable within 5 guesses to trick you.
But then you also know that he knows that you know that he could pick difficult numbers too.
I'm not entirely sure if this invalidates Ballmer's advantage, but I would be interested to know what the 'perfect' strategy would be for this game considering the meta-game.
If we accept cheating is allowed, we can also potentially accept other 'cheating' scenarios where the player repeatedly punches Ballmer in the face until he discloses the number, thus winning. Or where the player just refuses to pay at the end.
IMO the problem is only interesting if we assume any form of cheating isn't allowed.
Here, you can play the game with me. Higher. Lower. Higher. Higher. Lower. Correct. Six guesses, you owe me $1.
if I started off by guessing 50 twice you're cooked. or 50 and 52.
> secondly because the expected value of the game (assuming Ballmer chooses randomly) is negative: you end up paying Ballmer
Deep down we all know what programming, was supposed to be about, which is when you drop the ego and channel your childlike creative curiosity to create something you love, or to find like truth. People who know how to reliably find this state and enjoy it will become an “intelligent” person regardless of their original IQ. When I hire a full time role now, I look for people who are best able to channel this in the context of our team and our mission.
The problems come in when the creative output of the programming is being managed in a capitalistic system. If you take capital with the plans to build something and make money, then you have an entirely new set of constraints. You committed to a deadline so now you lose the ability to say “no”. Most programmers hate scrum/agile with a passion because these processes are basically the manifestation between the conflicts and misunderstandings that happen between shareholders and creators.
To which he literally has no answer: "I learned you need to step back and really ask if you're going to make money on this thing".. uh, okay Steve. Cool. Thanks for your contribution to possibly the worst technical hiring practices in just about any professional field. The technicals are less interesting than seeing even he himself has no real justification for this kind of intellectual hazing.
Well, honestly, once to several times a week during backlog grooming, meetings with stakeholders and other similar stuff. I find it much easier to work with people with fast recall who can be confident and correct even under time pressure. Nobody wants to sit through many time-consuming meetings that end with “we will check that and get back to you later”.
There is a succinct chess joke that summarises what being an expert means: a journalist asked Casablanca how many moves he thinks ahead. He replied, only one, but it is always the best one.
With that said, I wanted to share the following. Perhaps it will spur discussion.
Our leadership -- whether in our professional circumstances, in our sovereign and communal circumstances, or in our choice to lead ourselves; perhaps it is in these leaders that a view, or a decision, or a proclamation -- perhaps it is in these impulses that the world is changed.
Can you assign truth to an impulse? Is it a communication for consideration? Is it a demand for compliance?
I assert that you can do so. The words were spoken. Thus, the impulse was true.
If you desire to do so, please consider.