r/ProgrammerAnimemes • • Jan 11 '22

Most likely your first programming interview

Post image
968 Upvotes

50 comments sorted by

View all comments

Show parent comment

2

u/thatdude624 Jan 12 '22

Interesting, thanks for looking into that xD

Another slight improvement I've thought of: When initialising the set of unvisited points, calculate the maximum sized circle centered at that point. Pretty simple calculation: Find the minimum distance from that point to every line segment of the target shape.

Now consider unvisited points in order of circle size (a HashSet no longer works here but whatever) instead of randomly, and instead of starting with an infinitely small rectangle you can now start with the largest square that fits in the point's bounding circle (just some math).

Admittedly this won't work in any of your example test cases, but I imagine realistically shapes will be larger than just enough to fit exactly one suction cup on (not that your example is invalid). The heuristic should avoid marking large areas for gripping completely with small rectangles extending from other obscure features, as those would now only be marked later.

Another use case that'll break my algorithm is very small, very frequent holes: Since the gripper has multiple suction cups with some empty space between them, it would technically be possible to place the gripper such that the space between suction cups is positioned between gaps. My algorithm assumes we need a continuously flat surface.


Some more points on actual input shapes: The exact use case for this (kinda avoided it for anonymity but whatever) is stone cutting, like marble and such for fancy tables and kitchen tops. Holes are for sinks, taps, stovetops, cutouts for those little walls that seperate kitchen and dining room and so on. These are not super mass-produced, but they're extremely heavy, so these guys have a robotic solution to automatically load them from the output conveyor onto a palette.

Can these stone cutting machines produce really small holes? Are these stones ever cut to any bizarrely exotic shapes that don't resemble the rectangle they start as? I honestly don't know. If I got the job I'd probably be able to get more details on the actual manufacturing constraints which would help with figuring out what kind of cases the algorithm would actually need to cover.

Would be nice to have a mathematically optimal solution to any truly arbitrary shape though xD

1

u/BrandonJohns Jan 12 '22

Makes sense, for that use case it probobly would find the optimal solution most every time. Sounds like the perfect time to order a stone grating ;D

I do love mathematically optimal solutions though! (as painful as they can be to find)