Gift-wrapping machine algorithm

Free Prompt3years before (2023) Post FreePrompt
16 0

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

Related Topics