DEV Community

Discussion on: Interview Question: A two-player card game

Collapse
 
craser profile image
Chris Raser

This is a great question. It's enough to get a feel for how a candidate goes about it, but is happily free of the usual algorithm pop quiz. I'll definitely steal this.

You mentioned something important that I think a lot of interviewers gloss over: prompting appropriately is not easy. I once bombed an interview because the interviewer kept hinting at something they wanted, but I wasn't getting the hint, and they really didn't want to go on until I did. I finally just said, "I'm sorry, I'm just not seeing what it is you're getting at. How about I carry on, and when I have a working solution we can circle back and talk about improvements." We did, and there was more vague hinting, but I never did figure out what they were after.

I think it's really important to have questions that actually call for the techniques you want to see. I love that a reasonable solution to this question might just be the initial Game class with some local variables for players' hands and scores, but that the extended questions kind of turn up the pressure and make creating a Player class, etc. It reveals something about the candidate's habits, and opens up an opportunity to talk about why they either introduced the Player class right off the bat, or why they waited until it was more strongly called for.