3 ms·
Except that, unfortunately, Carpenter gave a wrong solution, showing that he's somebody who likes to write complex code for the purpose of showing off, but he's
by Udik 12y ago
Except that, unfortunately, Carpenter gave a wrong solution, showing that he's somebody who likes to write complex code for the purpose of showing off, but he's not particularly interested in understanding the requirements. It would have been enough for Christine to say:
"Ok, let's try your code. I'll read out a list of moves and you'll show me how it works"
and the fact that the code doesn't work would have become obvious.
- picks_at_nits 12y agoHere is an ES6 fiddle with the completed solution. Where is the flaw? http://www.es6fiddle.net/i6gs4jik/ http://www.es6fiddle.net/i6gs4jik/
- Udik 12y agoThe flaw is in the design. You're passing to the tortoiseAndHare function an iterable, but the only data you have access to, as per requirements, should be represented by an iterator. In other words, you're not free to iterate the moves of the game as many times as you please; the moves come in a single sequence. Adjust your code to keep track of those moves, and the solution becomes (almost) equivalent to the simple one.
- picks_at_nits 12y agoI think a good interview process would involve suggesting that the solution as given does not meet that interpretation of requirements, and asking the candidate to discuss/adjust, as you suggest. A poor process would fail the candidate outright without discussion or explanation. You’ll notice, for example, that Christine asking him to try out his code while she reads out the moves doesn’t match the template she provided, either. JM2C.