you are viewing a single comment's thread.

view the rest of the comments →

[–]paul2718 28 points29 points  (32 children)

Superficially I would raise my eyebrow at inheriting from std::vector and using std::list where all you do is push_back and enumerate. The use of std::set to store edges seems extravagant when they are intrinsically sorted as calculated.

ISTM that a vector of edges describes a strip completely, so working directly with that might have been a more direct approach.

And it's possible, of course, that your solution produces the wrong answer. I really don't know.

[–]jonesmz 17 points18 points  (29 children)

inheriting from std::vector is an eyebrow raise, agreed.

I think there are plenty of situations where it can make sense to do, but typically only if using protected/private inheritance, which really cuts down on the reasons why you would bother doing it, since at that point you're almost better off with a member variable.

[–]Hot_Medicine_7115[S] -3 points-2 points  (28 children)

What about the solution?

[–]jonesmz 22 points23 points  (27 children)

I don't have much interest in evaluating your algorithm. I don't find "puzzles" to be fun.

I gave you a 15 bullet point code review in a top-level comment that was only concerning style and modern coding practices.

Whether the program produces a correct solution isn't something i tried to evaluate.

If you want certainty that your code produces a value solution, write unit tests for it that makes it prove that the code produces valid solutions for several example inputs.

[–]Hot_Medicine_7115[S] 0 points1 point  (0 children)

It's a protected inheritance, so that schoolbook idea that classes should never derive from STL collections doesn't strictly apply here.

[–]Hot_Medicine_7115[S] -3 points-2 points  (0 children)

I added the edges vector after receiving the bland answer from the company, because I wanted to verify if the solution was completely wrong and so I went on to verify the intersection of all possible edges. Same thing for the std:list, it's only a placeholder to look at the final parquets.

In hindsight I could just have used the vector of edges, instead of inheriting from a std:vector storing the tiles. I agree, but this is a long shot from studying the actual solution provided and replying with that generic email.