Hacker News new | past | comments | ask | show | jobs | submit login

The thing that gets me about coding challenges restricted to such a short time frame is that what might seem like a simple problem can actually be pretty nuanced. This gets even more tricky when the interviewers encourage you to be "creative", which can be interpreted as meaning that one should try to be less conventional with how they code, which may mean they address an issue in a less than pragmatic way.

Last year, I interviewed with a well-known media company, and they gave me a take-home coding challenge which was essentially about building a notes application in Rails that philosophically replicated a file system; notes could exist in any part of a hierarchy of directories, but no same file could exist in multiple directories at once.

Seems pretty simple, right? Anyone with a fair amount of experience with Rails would probably whip up some models for folders and notes, folders would has_many :folders and has_many :notes, and notes would belong_to :folder, etc. A solution along those lines would probably have sufficed for the coding challenge, as it would demonstrate knowledge of Rails.

But I couldn't just leave it there. That kind of solution would have been extremely crappy in a situation where there is a huge amount of notes in deep directories. After a few hours of careful thought, I came up with a solution similar to how Amazon S3 works, where directories are really just keys in a database and the stored files(or notes in this case) are the values of those keys.

My solution had the advantage that directories and their files could be queried through simple string matching, meaning that queries scale linearly with deep and complex directory structures rather than exponentially. The only case where things might be less optimal is during directory renames, in which case all sub-directories and files would have to be found and updated, but I considered that a compromise since renames happen less often than reads and writes.

They liked my solution enough that they flew me out for an on-site interview, and they said that nobody else came up with that solution.

Would I have come up with that solution if I was given 60 minutes and had someone looking over my shoulder? Probably not. Such limitations prevent taking time to think and letting the mind ponder, which is valuable.

If that challenge was done in 60 minutes, they would have assessed that I knew Rails but probably wouldn't know how I actually approach problems.




Great example. I was doing a sudoku solver for practice recently and I spent a lot of time thinking and writing small functions, to the point where I was done but without implementing backtracking (for hard puzzles). I believe readability is a top 1-2 trait and my solver code looked fantastic. I don’t think I could do that under stress of an hour interview.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: