Gift-wrapping machine algorithm
This year, the elves invested in a gift-wrapping machine. However, it isn’t programmed! An algorithm that aids it in the task must be developed. Many presents are given to the machine. Each present is a string. Each gift must be wrapped by the machine and set in a display of other wrapped gifts. To wrap a gift, you must place the wrapping paper around the string, which is represented by the * symbol. For instance: const gifts are [“cat,” “game,” and “socks”]. console.log const wrapped = wrapping(gifts) (wrapped) / [“ncatn,” “ngamen,” and “nsocksn**”] */ As you can see, the thread is wrapped in the wrapping paper. The corners are also wrapped in wrapping paper on the top and bottom to prevent any gaps.
© Attention
The copyright of the book belongs to the book author and Amazon for unified interpretation, the blog belongs to the author's own interpretation, and the prompt is unified by the Internet. If you have objections to which ones, please click on the contant us page, and I will delete them to protect your interests.
If you want to reprint, please let me know, thank you.
Related Topics
No comments...