2 ms·
So, I agree that the interviewee in the story did the correct thing, but the part where they are describing their reframing of the question ("So, I am to write
by angersock 12y ago
So, I agree that the interviewee in the story did the correct thing, but the part where they are describing their reframing of the question ("So, I am to write an algorithm that takes a possibly infinite stream of…”) and then are just cut off (interrupted, as the story says) is kind of what I'm getting at. Like, if that happened in normal conversation, you kind of assume that either the person you're talking to is an asshole, or they are correcting your course because you are going down the wrong path.
That, plus the setup of the code with all the variables right there, meaning that you'd of course be tempted to break encapsulation and solve the problem by just adding a "visited" flag to each board[x][y] cell. That's the smarter engineering thing to do, because you a) have access to that state as the problem is setup and b) know that visiting any cell will only ever land you in the same successive cell.
Again, the question is bad because it takes a reasonable question ("Can you detect this loop?") and then foists on the interviewee boilerplate that literally begs to not follow the problem constraints.
- rayiner 12y agoGood point.