3 ms·
Last xmas I worked on a side project that ended up requiring a moderately substantial algorithm; much more involved than anything I've ever had to do in a LeetC
by andrewingram 4y ago
Last xmas I worked on a side project that ended up requiring a moderately substantial algorithm; much more involved than anything I've ever had to do in a LeetCode interview - there's absolutely no way i'd be able to produce it under those circumstances. Yet, the algorithm wasn't the hard part.
The hard part was all the exploration I had to do around the problem to get to the point where I understood the constraints well enough to solve it. I had to rewrite my attempted solution a number of times as my understanding grew. In my opinion, this represents the real thing we should be trying to test - a candidate's ability to unearth the true definition of the problem. When it comes to writing real world algorithms, whether you can solve it in 30 minutes or 3 days is (mostly) irrelevant, because it makes up such a small part of the overall engineering time.
You could squint and make a case that this is what LeetCode challenges are doing, but I'd only agree if we removed the requirement/pressure to have working code passing all the tests within the time allocation; and to be honest, most of them just hand you all the constraints on a platter.
- samsquire 4y agoI'm curious - could you tell us what the algorithm was?
- andrewingram 4y agoIt was somewhere between a sudoku solver and wave function collapse. Had to work out what tiles to use to accurately reproduce the slopes for rendering a Mario Maker 2 level. Most of the level tiles are just X/Y/TileID, but for slopes all you know is the start/end nodes. So you have to look at all the adjacent tiles to work out the correct TileID to use for each X/Y paid within the bounding box of the slope. But there's also ambiguity where there are multiple possible tiles with the same edge properties, so I had to work out the right priority/weighting to favour certain tiles over others. I had to derive and then write out all the edges rules by hand, which was many hundreds of lines.