Click here to Skip to main content
15,885,126 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
I have a bookshelf that looks like this.

The measurements of the same bookshelf. Other than the topmost rectangle which has a height of 42cm, the rest of them are equal and smaller i.e. 35.5cm. The width of all rectangles is the same i.e. 55cm and the extra non-rectangle one-side open portion is 25cm thus the total width of the shelf is 80cm. In a simplified diagram, it looks like this.

I purchased 10m USB-based string light (which has a USB port on one end and is just a linear piece of wire with bulbs on it) and this is supposed to go along the front rims of the shelf (cannot go inside as books are placed) starting from ORIGIN point (marked in red) which is where its power source is. I intend to tape over it so that when I switch it on, the shelf lights up beautifully. I'm trying to find the best path to take to cover the entirety of the bookshelf. I do not see a single straight pathway and so overlapping is unavoidable. However, since it is unavoidable I would like to overlap the main rectangles if possible to maximize the bulbs and give the bookshelf the best overall appearance. How can I determine the best pathway for this structure? Thanks.

What I have tried:

I tried reading up on dynamic programming esp. the Travelling Salesman Problem which I believe could be used to solve this but I couldn't quite figure out a solution.

A mathematical solution would be to add up the distances and then dividing it by the total, which led me to find that the wire goes twice around with 112cm to spare, which I believe would be suitable to be around the bottom. However, I wasn't happy with the solution and would love to see if a computer solution can be found.
Posted
Updated 10-Jan-23 21:43pm
Comments
CHill60 11-Jan-23 8:33am    
Persist with your reading, I would say you are in the right area of research, try some code, then return here if you have a specific problem. We are not a coding service, nor will we do your research for you. Perhaps share as far as you got with a solution
[no name] 11-Jan-23 13:33pm    
You have to visualize a solution before you can program it (the "algorithm"). Saying you're simply "unhappy" with what you've come up with so far is not something most people can work with (they are neither happy nor sad about it).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900