Mastermind Game

Watch someone solve the mastermind game problem in an interview with a FAANG engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Interview Summary

Problem type

Mastermind Game

Interview question

Implement a TCP client that solves the mastermind game served by HOST, PORT = 'www.marktai.com', 25565 Secret answer: 4 digits [1-6] inclusive Deduce the secret answer in under 40 guesses

Interview Feedback

Feedback about Immutable Goat (the interviewee)

Advance this person to the next round?
Thumbs up
How were their technical skills?
4/4
How was their problem solving ability?
3/4
What about their communication ability?
4/4
Nothing new in here, same as verbal feedback. For the Airbnb onsite criteria, I would give a slightly weak pass with a note about algorithms. If nobody else in the interviewing committee saw issues with algorithms, I would be comfortable passing. Algorithm: - quickly deduced algorithm after gathering key observations - pattern matched a little too hard on which algorithm to apply and using sets as a data structure - I'd recommend gathering observations first, then trying to see what previous experience fits Execution: - Pretty quick implementation of algorithm + TCP - some python unfamiliarity - multiply on arrays - strings are immutable - tried to ''.join integers - too much javascript programming with !== - Very fast debugging Communication: - Very clear communication both verbal and written - If applicable, try to proactively clarify call out your confusions, and even better ask clear questions - Very receptive to feedback If you're curious, here's the 5 guess worst case algorithm: https://en.wikipedia.org/wiki/Mastermind_(board_game)#Worst_case:_Five-guess_algorithm

Feedback about Orange Coyote (the interviewer)

Would you want to work with this person?
Thumbs up
How excited would you be to work with them?
4/4
How good were the questions?
4/4
How helpful was your interviewer in guiding you to the solution(s)?
4/4
Great question that was fun and interesting to solve! Interviewer was friendly and engaged and gave helpful prods and nudges!

Interview Transcript

Immutable Goat: Hello?\nOrange Coyote: Hello?\nImmutable Goat: Can you hear me? I can hear you. Can you hear me? Great.\nOrange Coyote: Yeah, I can hear you.\nImmutable Goat: How are you doing?\nOrange Coyote: Good, how are you?\nImmutable Goat: Good.\nOrange Coyote: So yeah, I have two questions I can give you today. So I'm curious, what are you looking for out of this market experience and what companies are you planning to you for?\nImmutable Goat: Sure. Okay, so I was at Amazon for four years, so four years of experience as full stack. I'm actively interviewing. I have an onsite next week for Reddit and Zoox and Apple on sites next week and then I have a Google Tech screen on tomorrow. So that's like the most immediate one I'm studying for. And I also have a lot of full stack or sorry, front end ish challenges that have been coming up a lot, a lot of these has been coming up from all these tech screens and I know that they're going to be like big part of my onsite. So this is just like a regular thing I have been preparing for and been doing. But yeah, I'm aiming for the mid to senior role and I was part of the Amazon layoffs a month ago and yeah, just hardcore interviewing, hardcore practice and I'm looking for as brutal as humanly possible feedback and yeah, just go like just super go super hardcore. I want to get owned.\nOrange Coyote: Sure. Yeah. I have the question just for you then. So this is the airbnb onsite question. What language will you be using today?\nImmutable Goat: Python.\nOrange Coyote: Great choice. So this is a question that's typically supposed to be done in 40 minutes as part of our hiring bar, but you'll have the full hour and we can just discuss it afterwards. So for this question, let's just get right into it. This can actually take a good amount of time. So you are going to be implementing a TCP client that solves the mastermind game served by this host and Port, have you played Mastermind or Wordle before?\nImmutable Goat: I've played wordle.\nOrange Coyote: Great. This is the game that Wordle was actually based off of.\nImmutable Goat: Oh, cool.\nOrange Coyote: So there is a secret answer. Four digits, one through six, inclusive.\nImmutable Goat: Okay.\nOrange Coyote: And it's your objective to guess this secret answer in under 40 guesses.\nImmutable Goat: Okay.\nOrange Coyote: For context, this is a children's game where they typically guess, they try to guess in under ten guesses. And Donald Newh made an algorithm for this in five or less guesses, which I actually implemented for Wordle. And it's around the same five or less, I think, or four or less maybe with an average of three. Besides Point example of this game is 2236 is a secret answer.\nImmutable Goat: Okay.\nOrange Coyote: And then here's the client on the left and the server responses on the right. So Start gets an okay in return and then the first guess the client sends is 1234 and that will return a 20 where the two represents two digits are in the correct space and the answer.\nImmutable Goat: Right.\nOrange Coyote: This corresponds to the green letters in wordle, but you don't know which ones are green.\nImmutable Goat: Okay. Yeah. Got you. Okay.\nOrange Coyote: The second example is demonstrating the second number. If you guess 1243, you get a one one back where there is one digit in the correct spot and one digit in the incorrect spot.\nImmutable Goat: Okay.\nOrange Coyote: The third example showcases that extras are not counted. So in this one, two two. First two is in the correct spot and the second two is in the incorrect spot. Then the third two is totally ignored in the output.\nImmutable Goat: Still got you.\nOrange Coyote: It's the same as virtual algorithm if you've played around with that. And then the last one is just showcasing what happens when you get the right answer.\nImmutable Goat: Okay. And B is number of digits and correct but in wrong spot.\nOrange Coyote: Okay, right.\nImmutable Goat: Awesome. So when I think about problems that have to do with giving me a special passcode or different combinations, that generally kind of pushes me towards like a defperate search to build all the combinations. And that's something that is pretty trivial. It won't be that hard to do to do something where you just keep guessing different answers and then backtracking when your answer is wrong. And then we can do something smart where we look at the feedback and then make informed choices on what to look at next. But in general, a brute force to generate all answers would be looking at the branching factor, which is six digits. And then the depth of that tree would be four digits. Right. Because there's four digits we need to get to. So it'd be like six to the four potential answers. Right. And then you can do something really simple. Okay. But we want to stay with 40 guesses. Okay.\nOrange Coyote: And anything under 40 is the correct solution. You don't need to optimize.\nImmutable Goat: Okay, I got you. Let me see. That would be like a backtracking recursive solution that's pretty slow to get to the answer. I'm wondering if I do something like this, right, like a deference search and I guess one to six and then one to six. I'm trying to figure out if I can do something smart. Like if I actually just guess a number and then using the feedback intelligently, will I always get to the right answer in under 40 guesses? That's like my theoretical question. Can I intelligently use the guest feedback and guarantee less than 40 guesses?\nOrange Coyote: I think something has five or less. Yeah, you want 40 or less in your worst case for this algorithm. Donald LUTH has an algorithm for five guesses or less at worst case.\nImmutable Goat: Got you. Okay. I'm not sure how I'm going to bound this to be like, hey, you messed up because this went over 40 guesses. But I guess I would just run out of guesses. What is worth the answer?\nOrange Coyote: Nobody's come close to 40. Almost all correct solutions are 30 or less.\nImmutable Goat: Okay, got you. Okay. There's like one random thing I want to touch on was that I know for world there's like a way of measuring your distance to the answer, right. Which is like, there's like a way to measure how much information you glean for making a guess. And it's called bits or something, right. Like a unit of information gained. Like, if I guess a number and it's correct, you gain. Like, I watched a YouTube video about it, but I totally forgot. But there's something really cool about it. No worries. I think I can build a solution that's kind of smart. Here where I do a Defert search backtracking solution where I guess one of the six digits, and then based on the feedback I get from the guests, I can probably do some top down memoization to save, like, oh, this guess attributed to this number combination of accuracy. Right. And then when I see two numbers like this, it also makes me think, like, maybe a table. And then we want to only work on good guesses. Right. So I don't need to waste. I want to work on the best candidates to keep guessing on them.\nOrange Coyote: Yeah. One piece of feedback so far. I really like your pattern matching. I think it's a little over aggressive for this problem right now.\nImmutable Goat: Yeah.\nOrange Coyote: So one particular issue with memorization for this problem is that it's not easy to break this into sub problems, especially not sub problems that are repeatable because the answers are about the entire guess, all four digits at once. So it's fairly difficult to break this down, especially when it's not really broken down into sub problems.\nImmutable Goat: Right. I can't do it one digit at a time.\nOrange Coyote: There's many ways you can solve this problem, but I would encourage you to just get familiar with the way the guessing system and how certain strategies will interact and give you certain styles of information and see if you can optimize that before getting too in the the weeds of deciding the algorithm. Before deciding which technique you're going to use in the algorithm, before gathering too many observations about it.\nImmutable Goat: Okay. Got you. That's a good point. So what I can do maybe is if I just did this, let's attack it from fundamentals. Right? So if I make a guess 1234, I kind of need to decide what I need to do based on what the guest gives me back. I need to decide what to do. So let's say if I got zero for the first number, that means the second number has to also be zero, right? Because there's.\nOrange Coyote: No is that possible? So if the code was 4321, that would give you four.\nImmutable Goat: I see, I see. Okay. Got you. Okay. And also it's kind of like slot based too. So that's something interesting. So maybe something interesting is like, I can do like a slot one set, right? And these are like and I can do one for each for each of the slots, right? Yeah. And then, let's see, that could track potential numbers to use. And we start off it's like one to six, right. And then when I make a guess based on these numbers, I can start reducing down the answers. So let's just go through some examples. So let's say one of them is good. From here, I know that 1234, they're not in the right place. What's the best way to say this? What does one mean if I get that?\nOrange Coyote: So it would mean one of the digits is incorrectly placed and the other three are not in the answer at all.\nImmutable Goat: The other three are not in the answer at all. Okay, Dang, how can I use this to reflect changes to my sets? Let me see. Four is relevant digits, but not in right place. Should I also have a set of numbers that could fit there?\nOrange Coyote: Yeah. Just as a point of trivia, if you ever get a zero four, it would take 24 guesses to guess all permutations of four digits.\nImmutable Goat: Oh, okay. Got you. Okay, right, okay. I'm thinking maybe I should instead do like, addition. So if a number could fit there, I start adding to the set until I guess you have to do a combination of both. Right. Like, these numbers can't be there, and then also these numbers could fit there. Let me know if that makes sense. I'm trying to see if I should be doing something like where I remove numbers from my sets to be like, oh, yeah, this number can't be there for sure. But sometimes the information kind of presents itself as like, oh, there could be a four there. Like four could be accurate. In this case, this is saying that 1234 are like, good digits for any of these slots. So basically that's saying that four can't be here. I guess let's break this down is four can't be indexed four, and then this is also saying and then likewise for the rest. Then I can remove this helps me remove four numbers. And then what else is it saying? It's saying that 1234 could be in all of them or like one, two, three could be in slot four. So reverse that is one, two, three could be in index four and then likewise for rest. Right. So that's kind of what this is saying. What else? Let's say I got like, 1234 and it was like two and two. So two numbers are in the correct area and two numbers are not. I'm trying to figure out what information this tells me. Right? This tells me that this sucks because I don't know which information is right or wrong. How can I say, like, four will be there for right. So this is tough, right? I don't know which numbers to remove from which sets here, actually, or am I missing something obvious?\nOrange Coyote: So again, I focus a little bit less on the Set representation right now and try to just get the intuition about the problem. Sets is an intuitive data structure, but Mastermind proves difficult to extract information out of in a natural form for Sets.\nImmutable Goat: I got you. Okay, so I should aim to use something kind of different for this data structure.\nOrange Coyote: I'd highly recommend just try to gather intuition and observations about the way net Mastermind data. You can get infusible signal out of the mastermind answers?\nImmutable Goat: I can get useful signal out of the mastermind answers?\nOrange Coyote: Yeah, the server answers. Try to build up just a human intuition around that rather than trying to apply the algorithm first.\nImmutable Goat: A human intuition? What do you mean? Like trying to just guess it by hand or something? Like what I would do or something?\nOrange Coyote: Yeah, absolutely. That's personally, what I do a lot in interviews is where I just solve it by hand a little bit. Try to build up familiarity with the problem before I start committing to algorithms or data structures.\nImmutable Goat: Okay, let me start with just doing like if I were to try and answer this one, I would try and then the answer would tell me that none of them are useful and none of them in the right place. So that means I should change or it also tells me that there's no ones, right?\nOrange Coyote: Yeah, precisely.\nImmutable Goat: Okay, so then I can move on to two two two. This is not too expensive. I guess I could keep going until I get some hits, but okay, so two two two. I would say they would tell me there's two numbers in the right area and two numbers not in the right area. That would be 20020. Sorry. Okay.\nOrange Coyote: By the third example, you don't have the extra twos counted.\nImmutable Goat: Yeah. So maybe I could split here to doing like, I don't know which two twos are in the right area. So then now I can split into two two and then Xx and then Xx and two two and then try to solve it there. Okay, so let's just do that in order. Let's just do this one first. So if I did this, I would see that this two in front and.\nOrange Coyote: Then make sure as a human doing this, what's a good number to swap in for x. Right?\nImmutable Goat: Now let's try three three. I know they can be ones, right? Yeah. Okay. So then in this example, I would get nothing's in the right area and two numbers are now they're right, but they're in the wrong area. So mentally I should know that this.\nOrange Coyote: Should be.\nImmutable Goat: Oh, shoot. Okay, so now I know there's two two and one three. Okay, this is kind of like really good information. Now I know, like three out of four numbers to create. Right. Okay. But I know they're in the wrong area. And then here I would get there's two two in the right area. And then let's write three three and I guess that would lead to three numbers in the right area and zero here. So there's for sure. It's for sure. Two two three to start with. And the reason I know that all right. Actually yeah. Sorry.\nOrange Coyote: Yeah, go ahead.\nImmutable Goat: Either two two three or two two three X, right?\nOrange Coyote: Yeah.\nImmutable Goat: But the reason I know this is because my human intuition and I know that these two matches, so I'm not sure how to convert that to code to be like, oh, you knew that there's two two somewhere, and now you.\nOrange Coyote: Verify.\nImmutable Goat: How to codify. Verifying. Not sure how to do that.\nOrange Coyote: That's a good point.\nImmutable Goat: Yes.\nOrange Coyote: Is there a way you could construct your third and fourth guess to know exactly which? Well, there's more complicated logic you could do to implement this, but like, to get line 19 through intuition code, that but there's a there's a much simpler direction you can go to construct guesses to figure out exactly where the correct twos are on line 17.\nImmutable Goat: Is it much simpler way, yeah.\nOrange Coyote: You had the choices on X, right?\nImmutable Goat: Yeah.\nOrange Coyote: What is a way where you can get very clear information out? What can you swap in for X?\nImmutable Goat: Can I swap into X to get very clear information? And I already did the four two s right. So it has to be anything other than one and two.\nOrange Coyote: Yeah, there's a lot of options. Right. Twos doesn't make sense because we've already guessed twos.\nImmutable Goat: Yeah. Right. So I should do three.\nOrange Coyote: What I'm trying to get at is it's tricky to precisely codify information that's coming out when you have a little too many unknowns at once.\nImmutable Goat: Yeah. It's difficult to codify when it's okay.\nOrange Coyote: Yeah. If not three, you could go back to one.\nImmutable Goat: If not three, I can go back to one. Yeah.\nOrange Coyote: You can do something like this.\nImmutable Goat: Right.\nOrange Coyote: We don't need to be that optimal here.\nImmutable Goat: I know those are bad numbers. Okay. So I can really just try to clean up guaranteed numbers. Okay. So that's kind of cool. It's like dead numbers can be useful to verify good numbers. It's kind of a cool idea. Yeah. So then if I were to get after doing this, if I did, like, 2211, then I would get guaranteed information, actually. Right, right. Okay. That's kind of a cool idea. So, like, get a dead number, then use it as filler to find absolute slotted numbers. That's pretty cool. I like that. Then I could do something like 1211 and then keep trying these out. I probably do have enough guesses to do that. Right. So six times four each one.\nOrange Coyote: Yeah.\nImmutable Goat: Well, that kind of works. Right. So I can't do two and then one, and then this goes from two to six. I know that that works. And then do it for every slot, I guess. Does that make sense?\nOrange Coyote: Yes.\nImmutable Goat: Cool.\nOrange Coyote: One question, though.\nImmutable Goat: There must be a dead number, too.\nOrange Coyote: Yeah, one simplification you can actually apply. Do you even need a dead number for this approach? It certainly works with dead numbers, and if you want to move to implementation step with dead numbers, feel free.\nImmutable Goat: Okay. Yeah, because what you pointed out is something really awesome, which is like I think I'm introducing a lot of ambiguity. If I just keep throwing in more potential answers, then you're like getting your response all muddled, right? You're like, is it right because of the new number or is it right because I was testing an old number and I think it's right now. So I think that made it really confusing. Is there a way to do that without the dead number? It's not coming to me right now.\nOrange Coyote: But sounds free to go ahead to implement this with the dead numbers then.\nImmutable Goat: Okay, sounds good.\nOrange Coyote: So we're on the same page on your approach. What would be the worst case number of guesses for this approach?\nImmutable Goat: Okay, so I would have to do six guesses for the dead number, right. And then after that, once I find a dead number, then from each other for every slot. So four slots, I would try five numbers. That's another 20 guesses. So that puts me at 26.\nOrange Coyote: Yeah, precisely.\nImmutable Goat: Okay. This is so cool. Okay, is it cool if I try to implement this then?\nOrange Coyote: Yeah, go ahead.\nImmutable Goat: Okay. Dev mastermind guesser. Cool. Then what we're going to do is we're going to do some def guests and then I don't know, we'll abstract this out.\nOrange Coyote: Sounds great.\nImmutable Goat: Okay, let's write the pseudo code. I don't know why everything's freaking out. Okay. It's because I have functions. Okay, so let's see. Find dead number, then try every other non dead number at every slot, and then I'll lock in the right number for that slot and then submit answer. Okay, so from numin range one, two, seven. And then the interface for guests is it tells you the right numbers in the right spot, how many numbers in the right spot, and then I guess I'll just call it A and B equals guess of NUM. And I want my new guess equal to NUM times four. Definitely want this to be a string. How do you know if it's a dead number again, if there's zero for B? Right? We just care about B. That means like, there's no correct digits and none of them are in the right spot. Right? No correct digits.\nOrange Coyote: Actually really the sum of A plus B and one trivia about this is if you guess all the same number, b is always zero and it's always A. It's really A, not B.\nImmutable Goat: Okay, got you. Okay, let's say dead. Now that we have a dead number, let's try every number at that slot. So for the first index, so I got to build all these combinations out so it's index in range four. So what I got is I need to build a string that's made up of the number I want to test at that slot and then what slot I'm on, current slot. And then for nomin range, one to seven. Let me go ahead and build this out. So what I need is the current slam on right now is zero. So I want the first I want the zero index to be my answer. And okay, maybe I can do is just make a guess that's equal to this times four. So I want four slots. And then I will do I will okay. Actually a better way to do it is just to do new guess is equal to string of NUM times four. So now I should have a guess that looks like this. And then I want to plug in my dead number on the current slot you're on. So I'll do. New guess. Sure. There's a better way to do this, but it's pretty ugly. It's okay. Set item string. Well, I should be able to set the index of that string or strings are immutable. Goddamn right. Okay, what I can do is just something like this, and I want four of these strings. Okay. And then what we're going to do is try out let's say we did some random guess like this, right? If we get back, we want the answer to be one. One, right? Exactly. One and one. Actually no one in zero, right? Yeah. So if it's one and zero, that means that's the correct number for that slot. And I'll probably put that into the final answer like this. Let's go and do the guess again. If A is equal to one and B is equal to zero, this is the correct digit for this slot. So then I'll put final guess slot is equal to this number, I'm guessing. Cool. And then let's go ahead and submit the final answer, final guess, and I can return as a string. And these are numbers. I think they'll still work even though joining numbers, I think, but yes. Does this make sense so far?\nOrange Coyote: Yeah, absolutely.\nImmutable Goat: Okay, cool. It's going to be a little hard to test without the guesting.\nOrange Coyote: Yes, it will be. I forgot to mention, nobody memorizes TCP clients. You should look up an example of a TCP client and implement that. Pull out the relevant code and implement it in your solution. If you are having trouble finding a good TCP client example in Python Three, I'm happy to help you. I know examples in all the languages at this point.\nImmutable Goat: Okay, yeah, let's do that. Yeah, I'm not familiar with that yet. Do you have one for me?\nOrange Coyote: Yes, I do. I will paste a link right here.\nImmutable Goat: Oh, cool.\nOrange Coyote: Is that Python Two? Wait, apologies. This might be Python Two. I see a two on the top. Yeah, it's Python Two. My mistake, my mistake. I looked up Python Three and it gave me this, and it says Pymont W three and it gave me this. Gosh. It's so annoying.\nImmutable Goat: I probably need socket, right?\nOrange Coyote: Okay. Yeah. Okay, so I have the same thing, but just on three. So if you just I found out it was actually Google that replaced my Python three with just Python, hopefully.\nImmutable Goat: Okay, sweet. So let me import all this stuff, and then I need to create a socket and connect to it. Yes.\nOrange Coyote: And as a note about the server implementation, you'll need to open the same connection, keep that socket open, and then feel free to close it at the end. But for the entire game, you'll need to keep one socket open.\nImmutable Goat: Okay. Do we have a server address in port, or are we just making it up? Kind of? Yeah.\nOrange Coyote: Line two. This is a live server. I'm running it right now.\nImmutable Goat: Oh, sweet. This is so sick. Yeah.\nOrange Coyote: My name is Mark ty oh, really?\nImmutable Goat: I didn't know. Okay, we connected, and we want to try to guess, right? Okay. So let's do is try S send all, and we want to send a guess. Okay. So maybe I can make this into, like, a little mini method, which is def send guess and give me a guess and something like this. And we want to send the gas encode and data equals S. And let's receive it. Receive receipt four. And finally close. Don't you close this? May I close at the end?\nOrange Coyote: We want to keep the socket open for the entire yeah.\nImmutable Goat: Okay. I'm not going to do the try then. And return the data decode TF eight. Okay. I'm guessing there's going to be some bugs. I think this server thing makes sense. We're connected to that. We're doing that port send guests to the send all. And then I read back the data I get. I'm not doing any defensive coding or anything. Hopefully I'm sending a string.\nOrange Coyote: Error handling is not in scope.\nImmutable Goat: New string times four. This might be buggy. I think this is right to make a new string of four.\nOrange Coyote: Feel free to just run the code program to just test it. There's no requirement to do it verbally, and I can share the logs that I get on the server side.\nImmutable Goat: Sweet. Okay.\nOrange Coyote: And I have nothing.\nImmutable Goat: Okay. I got called a function.\nOrange Coyote: You need to call your main function?\nImmutable Goat: Yeah. And, you know, I might as well start adding some prints and okay, cool.\nOrange Coyote: So I received all ones. I'm not sure why it's printing, and the server is not responding to that. Make sure you're adhering to the spec on lines ten through 14.\nImmutable Goat: Oh, sorry. Okay, I got you. I got to acknowledge all this stuff, right? Yes. So I need you to send a start, right? Okay.\nOrange Coyote: Yes.\nImmutable Goat: Initiate contact like that. And we want to make sure we get back in. Okay. And I got to encode this, right? Data decode is not equal to okay. This is so ugly. Sorry. Okay, hopefully the game started now, and then let me go ahead and add this to the game and go ahead and do guess. Oh, I got to actually just prepend it. So guess server. Just go ahead and do this real quick.\nOrange Coyote: And don't forget the new line as well.\nImmutable Goat: Oh, got you. Okay. Oh, I'm not reading the answers properly either. Okay. So I should get this. I got to break down the answer too. I guess I just need the first index and the second the zero index and the second index. I could do that. Or I could probably do something smarter with stream parsing. But.\nOrange Coyote: Just do first and second or zero and second.\nImmutable Goat: Yeah, dollars.\nOrange Coyote: That's what I got on the server as well.\nImmutable Goat: Okay, got you. Let's see what messed up here. I guessed all six items and then did I find what the dead answer was?\nOrange Coyote: Let me go to the bathroom really quickly while you debug. Yeah, I'll still be able to hear you.\nImmutable Goat: Yeah. Okay, let's see. I did not find my dead number. I messed up here somewhere. So we tried it, tried one, one. We got two answers in the right place. We did all twos and then we got okay. And then there's a few more there. But this should have been a plus b here should have been equal to zero. Interesting. Why did I get okay, are good. I wonder why I didn't get oh, these are strings, huh?\nOrange Coyote: Yes.\nImmutable Goat: A equal to zero and B is equal to zero. The way strings and numbers are so sketch. Okay, I'll send you change out here then too. But hopefully this should give me my dead number now. Dead number five, one. Chris Lot got out of index. Okay. Zero. Okay. I'm guessing this file guess thing is pretty shit. I think it doesn't actually I'm trying to do I think we're like initialize an array of size something, but I should put something in there. Okay. And then I got turn these into strings. Okay, let's print it. Cool. Is that the answer?\nOrange Coyote: I don't think that's the correct answer. Let me double check. But there's a bug in your code.\nImmutable Goat: Okay.\nOrange Coyote: The correct answer is 3142. So look through your guesses. Look through the guesses that your program is doing.\nImmutable Goat: Okay, so 31421 has an answer. Two is somewhere in there. How did three get how did I say three have a number? There's a three. Sorry. And then five and six. Okay. Yeah. Okay. I should just break in here after you find a dead number. But anyways, six is still an okay dead number. And then I tried six and all ones. And what did we find? I need to guess the new number here. And the filler should be the freaking the filler should be my dead number. Okay, so let's see. And then the current slot should be the new NUM. Yeah. There we go. Okay, this is the number I want to guess. Let's try that again. Is. This closer.\nOrange Coyote: Your answer is 3614. And that's the correct answer. Nice job.\nImmutable Goat: Yeah.\nOrange Coyote: Can you write it one more time?\nImmutable Goat: Yeah. Great.\nOrange Coyote: Nice job.\nImmutable Goat: This is still.\nOrange Coyote: Yeah, this looks like it'll always guess in the maximum, which was 26 guesses.\nImmutable Goat: Yeah.\nOrange Coyote: Sorry. Can you reassess the max guesses of your algorithm, your implemented algorithm.\nImmutable Goat: To see where it's at right now?\nOrange Coyote: No, just logically look through your code and assess how many guesses it should take up.\nImmutable Goat: Max. Okay. I should guess six numbers here. This is six guesses. And then here, this is for every slot. That's four slots. Four slots. And then for every slot, I guess in those six numbers. So guessing there are six numbers is equal to 24 guesses. And then so now I should be at 30 total guesses.\nOrange Coyote: Yeah, perfectly fine. Under 40 is great.\nImmutable Goat: Okay.\nOrange Coyote: Good job. I would pass you for the airbnb on site. I would pass you and have a note in the comments. Your pattern matched pretty hard in the beginning.\nImmutable Goat: Oh, God.\nOrange Coyote: With some guidance, you got in the right direction, and once you found the right insights, you very quickly figured out the algorithm. Yeah. I can give a much more structured feedback, but how did you feel about the interview? What were your thoughts?\nImmutable Goat: Oh, I freaking love it. I think it's like, one of the it's really a game, so that's so sick. I really like that. And I did feel like I probably needed a lot of guesses, but I need a lot of hints to get towards pushing towards intuition. So I guess I'm used to like, oh, at the end, there will be a clean algorithm that follows the prompt exactly and kind of always moves towards a good answer. But I think one thing I didn't understand was the scale. Right? Because if there's only four digits and six numbers, the things you can do is not too bad. And you also throw out a hint about 30 guesses. Like, most people get under 30 guesses. So I definitely feel like, looking back, like, you're throwing me some really good bones. I need to pay a lot more attention to that. And also you were saying stuff about what does a guest tell you? Right. And so I was like, okay. And then once I reevaluate something from the beginning, let's just do all ones and then all twos and stuff, I'm like, okay, actually, this makes it a lot better, because you can work on one digit at a time and then start ruling out either one digit at a time or one slot at a time. Makes it a lot better. So that was really cool. And, yeah, I think definitely need to be a lot more critical. I need to use my critical thinking a lot better with the scale of the problem. Right. That should have been a nice tip off to be like, do you need to do anything crazy with backtracking and then also taking a critical look at how would you solve this as a human, that's also a really good thing to do is let's not just run to an algorithm. Let's try to like, if you had this in front of you, what would you do? And I really like that kind of thinking in general. So that was a really fun way of solving the problem.\nOrange Coyote: Yeah, you caught a lot of the points that I have in my notes, but I'll just go through all mine concretely as well. So I'll break down my feedback in terms of algorithm execution and communication, the exact same dimensions we use at Airbnb. So at the beginning for the algorithm, you definitely much too over aggressively try to fit this into the box of all your other experiences, which works most of the time, I will admit. Most of the time you just throw the algorithm at it, you see which one fits like a key, and then you're like, okay, I solved a lot of the times, if it's not going to fit that exactly, you will have difficulties. Yeah, I personally did. Similarly, in my experience, I found that coming with more of an open mind rather than immediately jumping into this, probably has an algorithm to just fit with it. So just more taking a higher picture maybe for like 1 minute and then thinking, okay, this probably fits with an algorithm, but I'm guessing that just having this interview question and having the experience of aggressively overfitting will probably be enough. You don't need to actively think about, am I overfitting? But I think you applied that in two directions of where you tried to apply the algorithm to the question and then you tried to apply the data structure to the question. Yeah, slots is definitely much more intuitive and kind of in the right direction of thinking like this problem, about this problem. But unfortunately, sets don't really it's hard to get the information so cleanly out with sets. It's much easier to just ignore sets entirely like we did here. So I think in both of those directions, if I hadn't prompted you otherwise, you probably could have spent maybe five to ten more minutes, both of them just being a little overfitted. So in general, I highly recommend gathering observations first. So one key observation that I did notice you gathered was the brute force approach and how that won't fit, but just highlighting that it exists is always a baseline.\nImmutable Goat: Right.\nOrange Coyote: I did notice that.\nImmutable Goat: You would have.\nOrange Coyote: Passed this interview, but to be strong passing or very confidently passing, I think you'd be the weak side of a pass and just having a note on the algorithm, but if there's no other issues with the other interviews and algorithms, I'd be fine to pass you. But to improve on that, what I would like to have seen is again, need for less prompting on some of the algorithm direction as well as making sure you're flexible. The key problem of this is that you need to figure out the right strategy to get clear information out. And so a lot of people get stuck in their strategy of thinking, okay, let's change a lot of numbers and try to be optimal.\nImmutable Goat: Oh, God. Yeah.\nOrange Coyote: I noticed that you were kind of stuck in trying to change as many things as possible. I don't know, just to try to find the information, but loosening your assumptions. Trying to think of a lot of different ways to tackle a problem sometimes can be really helpful. Sometimes it's just a waste of time. You're going to need to find the balance between, do I feel like what I'm doing now is making progress to the solution, or should I reevaluate?\nImmutable Goat: Okay.\nOrange Coyote: My rule of thumb is generally if I spend five minutes and I don't feel like I'm making significant progress, I'll check in with the interviewer, actually. So I'll be like, I'm not sure if this approaches actually will fit. What are your thoughts? Interviewer?\nImmutable Goat: I love that.\nOrange Coyote: Hopefully insert their name. And so you give the choice to them whether they want to be stonewalling you and just watch you struggle, or they can offer a little bit of prodding and saying, no, I think trying something different would be appropriate. I've never personally seen someone have an interviewer have an issue with a candidate, somewhat open ended, asking for an option rate. Yeah. They don't have to answer if they don't want to.\nImmutable Goat: That's true.\nOrange Coyote: But yeah, that's my thoughts on the algorithm.\nImmutable Goat: Yeah.\nOrange Coyote: Does that make sense? Any questions on that?\nImmutable Goat: Yeah, that makes a lot of sense.\nOrange Coyote: You're taking notes, too? I have the same thing written down.\nImmutable Goat: I also forgot to attack the crux of the prompt, too, about the TCP client, too. That's why I slipped my mind. I was just so focused on the little number thing. I think that's important thing in general.\nOrange Coyote: Yeah. You just accidentally happened on the right way to tackle this problem of ignore TCP until the very end. Because the reason that I give this problem, especially for mock interviews, is it stresses people the crap out. They can't pattern match. They don't know what TCP is. So it puts people under a lot of pressure and exposes a lot more ways you can improve, especially under pressure of a real interview.\nImmutable Goat: Right? Yeah. I was like, network.\nOrange Coyote: Yeah. As far as execution, I noticed some Python unfamiliarities in a lot of areas. Did you use Python on the back end?\nImmutable Goat: I actually haven't used Python for the back end. I just use it for a lot of data. striction algorithm stuff. Yeah. So there's a lot of stuff here. Okay.\nOrange Coyote: It wasn't so much ugly, but I noticed on line 53 you had the empty array times four. Yeah. I noticed your first attempt was to modify the string, but strings are immediately called out, like doing the string join on integers. I laughed on line 31 where you did the not equals equals style.\nImmutable Goat: Yeah, these are all that's why I was like, oh my God, of course there's not three equals.\nOrange Coyote: I see. Okay, it's fair. But you might also want to just consider doing these in JavaScript if that's what you're more familiar with. I personally think that Python and JavaScript are around similarly good for interviews, but whichever you're most comfortable in, but whichever you are most comfortable in, I'd recommend grinding and getting very familiar with all these small things and the standard library. I know you have interviews tomorrow, so I don't know about that, but besides that and the execution, the only major there's a lot of small bugs all over, but you figured them out pretty quickly, right? Yeah, I mean, your debugging is actually pretty fast. For what it's worth, I was noticing the time at the end and I was worried that debugging could take maybe five to 15 minutes, but you were pretty quick about that. Of course it saves time to not write debugs in the first place, but.\nImmutable Goat: Who'S going to do the first time? Yeah.\nOrange Coyote: Let'S see. And then on communication, I really appreciated your clear written and verbal communication. Taking notes during this part is also great. I'd be very happy with the candidate if I see them taking notes of what I'm saying. As I'm saying it, it's a good habit. It shows clear listening and communication skills and it's very easy for me to catch if you are confused about something.\nImmutable Goat: Right.\nOrange Coyote: What I did notice is I noticed a couple of times you didn't actually have the like when you were trying to figure out the answers that the server would give for a number. You got that wrong a couple of times. I wasn't sure if that was because you didn't clearly understand how the server gave the answers or not, which could be poor communication on my part. But if that was the case, then maybe proactively communicate your confusion and as the next step very clearly ask a question on what you're confused about. But if you had the right idea, but you just get the numbers all mixed up common, then that's no big deal, right.\nImmutable Goat: I think I was a little sloppy, right? Like I wasn't double checking on what the TCP client is or like I didn't even ask what this host import was for and also part of verifying what this interface means. What does the server give, what should I give it and what should I get back?\nOrange Coyote: It's actually incredibly common. People always forget that. I think 90% of candidates forget to actually do the interface.\nImmutable Goat: Yeah, I think if I just took a minute to be like, well, how do I when I send a guest, what do I get back? And then you would point to me here and be like, okay, now I'm like, okay, this makes a lot of sense. And also this here, I didn't know that this was like a little handshake thing at the beginning, but that's obvious now that I know we need to interact with the server. That makes a lot of sense. I think it's just like, very good practice to do that to clarify your interfaces.\nOrange Coyote: Yeah, absolutely. I thought your communication was excellent, by far better than most people, and most people have passing communication already. Awesome.\nImmutable Goat: Yeah.\nOrange Coyote: Do you have any thoughts, questions?\nImmutable Goat: Oh, yeah, no, this problem was really fun. I liked it a lot and it definitely taught me some really good pieces here, for sure. And yeah, this is kind of unrelated or random, but if you have anything you think would be worth also grinding on past this interview, like any homework, I'd love to do that too, because this is a pretty good learning experience.\nOrange Coyote: I'm not familiar with the Google Reddit Zooks or Apple interview questions. I honestly haven't interviewed as a candidate in a while.\nImmutable Goat: Good, no problem.\nOrange Coyote: But I give a lot of interviews, so that's what I'm more skilled.\nImmutable Goat: Do you do any front end interviews too?\nOrange Coyote: No, I was an infrastructure engineer.\nImmutable Goat: Got you. Okay. I was wondering, what does Airbnb like to ask if they do front end interviews? Because front interviews are so random. It's always like, build this calendar or something and you're like, okay, you can use raw JavaScript. It's always like you never know what's going to show up.\nOrange Coyote: You can't import anything. Oh, God. I don't think we have front end interviews. I think the only specialist is for mobile. Awesome.\nImmutable Goat: Okay.\nOrange Coyote: So I have no advice for that.\nImmutable Goat: Got you. Awesome. Well, this has been really great and yeah, thank you for the prom. It's really good.\nOrange Coyote: My pleasure. Yeah, best of luck on the rest of your views and have a great day.\nImmutable Goat: All right, thank you. Bye.

We know exactly what to do and say to get the company, title, and salary you want.

Interview prep and job hunting are chaos and pain. We can help. Really.