String Shuffle (Python)
String Shuffle (Python)
Watch someone solve the string shuffle and analysis problem in an interview with an interviewing.io engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.
Shuffle String (Python Interview) - YouTube
Shuffle String (Python Interview)
Interview Summary
Problem type
String shuffle and analysis
Interview question
Write a function that takes a string as an input and returns a shuffled version of that string (i.e. a version where each character is just as likely to be in any given position)
Write a function that analyzes how well your previous function randomly shuffles the string
Interview Feedback
Feedback about Stateful Armadillo (the interviewee)
Advance this person to the next round?
Yes
How were their technical skills?
4/4
How was their problem solving ability?
3/4
What about their communication ability?
4/4
Feedback about Adequate Lobster (the interviewer)
Would you want to work with this person?
Yes
How excited would you be to work with them?
3/4
How good were the questions?
3/4
How helpful was your interviewer in guiding you to the solution(s)?
4/4
Solid interview.
The amount of hints dropped kept the interview moving along, which is important (nothing is more frustrating to me than radio silence and me just blabbing and going down the wrong path and wasting all our time).
Interview Transcript
Stateful Armadillo: Hello?
Adequate Lobster: Hey how's it going?
Stateful Armadillo: Good how are you?
Adequate Lobster: Good. You probably know the drill but go ahead and pick a language that you're comfortable with and we'll get started. Unless you want to do something else first?
Stateful Armadillo: No we can hop right into it?
Adequate Lobster: Great. It's a two-part question and the first part is not important that you get it exactly right or anything like that. We can talk through the solution at the end and make sure you have something that makes sense but it doesn't have to be perfect.
Stateful Armadillo: Okay.
Adequate Lobster: So the first part is I want you to write me a function that takes a string as an input and returns a shuffled version of that string. As in a version where each character is just as likely to be in any position.
Stateful Armadillo: Okay. So def shuffle(). So what I'm thinking here for a simple shuffle is, I can do two random index swaps converging in the middle maybe. I can go for that approach I guess. So is it okay to use random? I assume it's okay to use random.
Adequate Lobster: Yeah sure.
Stateful Armadillo: I think random is in the math library. No it's in the random library.
... (truncated for brevity) ...
Stateful Armadillo: Yeah, that makes total sense. It's funny, looking back on the problem it's obvious. This is literally a conversation I had with someone about writing a test for a random sequence generator we had and it was almost the same sequence of conversation: just run it more.