Re: Packing Problem

2023-03-18 Thread Rob Cliffe via Python-list
f Rob Cliffe via Python-list Date: Thursday, March 2, 2023 at 2:12 PM To: python-list@python.org Subject: Re: Packing Problem *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Slightly improved version (deals with multiple charac

Re: Packing Problem

2023-03-02 Thread Weatherby,Gerard
: python-list@python.org Subject: Re: Packing Problem *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Slightly improved version (deals with multiple characters together instead of one at a time): # Pack.py def Pack(Words):

Re: Packing Problem

2023-03-02 Thread Rob Cliffe via Python-list
Slightly improved version (deals with multiple characters together instead of one at a time): # Pack.py def Pack(Words):     if not Words:     return ''     # The method is to build up the result by adding letters at the beginning     # and working forward, and by adding letters at the end,

Packing Problem

2023-03-02 Thread Rob Cliffe via Python-list
I found Hen Hanna's "packing" problem to be an intriguing one: Given a list of words:     ['APPLE', 'PIE', 'APRICOT', 'BANANA', 'CANDY'] find a string (in general non-unique) as short as possible which contains the letters of