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
: 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):
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,
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